aace812bd63d562dafc4b6cf8bc521c6ccee759b.svn-base 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
  5. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  6. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  7. <el-select v-model="table.getdataListParm.parammaps.barid" filterable placeholder="栏舍名称" class="filter-item" style="width: 120px;" clearable>
  8. <el-option v-for="item in houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  9. </el-select>
  10. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  11. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  12. </div>
  13. <div class="operation">
  14. <el-button v-if="isRoleEdit" icon="el-icon-plus" class="success" style="float: left;margin-right:10px;" @click="handleCreate">新增</el-button>
  15. <el-button v-if="isRoleEdit" icon="el-icon-delete" class="danger" style="float: left;margin-right:10px;" @click="handleDelete">删除</el-button>
  16. <el-button v-if="isRoleEdit" icon="el-icon-copy-document" class="copy" style="float: left;margin-right:10px;" @click="handleCopy">复制</el-button>
  17. <el-upload v-if="isRoleEdit" style="float: right;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  18. <el-button class="import" icon="el-icon-download" style="float: right;">导入</el-button>
  19. </el-upload>
  20. <el-dropdown style="float: right;margin-right: 10px;">
  21. <el-button class="export" icon="el-icon-upload2">导出</el-button>
  22. <el-dropdown-menu slot="dropdown">
  23. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  24. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  25. </el-dropdown-menu>
  26. </el-dropdown>
  27. <el-button class="export" style="float: right;" @click="handleHistoryRecord">历史记录</el-button>
  28. </div>
  29. <div class="table">
  30. <el-table
  31. :key="table.tableKey"
  32. v-loading="table.listLoading"
  33. element-loading-text="给我一点时间"
  34. :data="table.list"
  35. border
  36. fit
  37. highlight-current-row
  38. style="width: 100%;"
  39. :row-style="rowStyle"
  40. :cell-style="cellStyle"
  41. class="elTable table-fixed"
  42. @selection-change="handleSelectionChange"
  43. >
  44. <el-table-column type="selection" align="center" width="50" />
  45. <el-table-column label="序号" align="center" type="index" width="50px">
  46. <template slot-scope="scope">
  47. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="栏舍名称" min-width="100px" align="center">
  51. <template slot-scope="scope">
  52. <span>{{ scope.row.barname }}</span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="第一层" align="center">
  56. <el-table-column prop="onerate" label="比例(%)" min-width="65px" align="center" />
  57. <el-table-column prop="oneweight" label="重量(g)" min-width="65px" align="center" />
  58. </el-table-column>
  59. <el-table-column label="第二层" align="center">
  60. <el-table-column prop="tworate" label="比例(%)" min-width="65px" align="center" />
  61. <el-table-column prop="twoweight" label="重量(g)" min-width="65px" align="center" />
  62. </el-table-column>
  63. <el-table-column label="第三层" align="center">
  64. <el-table-column prop="threerate" label="比例(%)" min-width="65px" align="center" />
  65. <el-table-column prop="threeweight" label="重量(g)" min-width="65px" align="center" />
  66. </el-table-column>
  67. <el-table-column label="备注" min-width="90px" align="center">
  68. <template slot-scope="scope">
  69. <span>{{ scope.row.remark }}</span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="操作人" min-width="90px" align="center">
  73. <template slot-scope="scope">
  74. <span>{{ scope.row.emp }}</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="操作日期" min-width="90px" align="center">
  78. <template slot-scope="scope">
  79. <span>{{ scope.row.operatetime }}</span>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="操作" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  83. <template slot-scope="{row}">
  84. <el-button v-if="isRoleEdit" icon="el-icon-edit-outline" class="miniSuccess" @click="handleUpdate(row)" />
  85. <span v-if="isRoleEdit" class="centerSpan">|</span>
  86. <el-button v-if="isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
  87. </template>
  88. </el-table-column>
  89. </el-table>
  90. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  91. </div>
  92. <!-- 新增/编辑 -->
  93. <el-dialog :fullscreen="dialogFull" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  94. <template slot="title">
  95. <div class="avue-crud__dialog__header">
  96. <span class="el-dialog__title">
  97. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  98. {{ textMap[create.dialogStatus] }}
  99. </span>
  100. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  101. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  102. <svg-icon v-else icon-class="fullscreen" />
  103. </div>
  104. </div>
  105. </template>
  106. <div class="app-add">
  107. <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="150px" style="width: 100%;margin:0 auto 50px">
  108. <el-row>
  109. <el-col :span="24">
  110. <h3 style="width: 150px;text-align: right;">栏舍信息</h3>
  111. </el-col>
  112. </el-row>
  113. <el-row>
  114. <el-col v-if="create.dialogStatus=='create'" :span="8">
  115. <el-form-item label="栏舍名称:" prop="barid">
  116. <el-select ref="barid" v-model="create.temp.barid" filterable placeholder="栏舍名称" class="filter-item" style="width: 100%;" @change="changeBar">
  117. <el-option v-for="item in houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  118. </el-select>
  119. </el-form-item>
  120. </el-col>
  121. <el-col v-else :span="8">
  122. <el-form-item label="栏舍名称:" prop="barname">
  123. <el-input ref="barname" v-model="create.temp.barname" disabled class="filter-item" placeholder="barname" />
  124. </el-form-item>
  125. </el-col>
  126. </el-row>
  127. <el-row>
  128. <el-col :span="24">
  129. <h3 style="width: 150px;text-align: right;">重量比例</h3>
  130. </el-col>
  131. </el-row>
  132. <el-row>
  133. <el-col :span="8">
  134. <el-form-item label="第一层重量(g):" prop="oneweight">
  135. <el-input ref="oneweight" v-model="create.temp.oneweight" class="filter-item" placeholder="最多两位小数" type="number" step="0.01" style="width: 100%;" @blur="blurWeight" />
  136. </el-form-item>
  137. </el-col>
  138. <el-col :span="8">
  139. <el-form-item label="第二层重量(g):" prop="twoweight">
  140. <el-input ref="twoweight" v-model="create.temp.twoweight" class="filter-item" placeholder="最多两位小数" type="number" step="0.01" style="width: 100%;" @blur="blurWeight" />
  141. </el-form-item>
  142. </el-col>
  143. <el-col :span="8">
  144. <el-form-item label="第三层重量(g):" prop="threeweight">
  145. <el-input ref="threeweight" v-model="create.temp.threeweight" class="filter-item" placeholder="最多两位小数" type="number" step="0.01" style="width: 100%;" @blur="blurWeight" />
  146. </el-form-item>
  147. </el-col>
  148. </el-row>
  149. <el-row>
  150. <el-col :span="8">
  151. <el-form-item label="第一层比例 (%):">
  152. <span>{{ create.temp.onerate }}</span>
  153. <span>{{ create.temp.onerange }}</span>
  154. </el-form-item>
  155. </el-col>
  156. <el-col :span="8">
  157. <el-form-item label="第二层比例 (%):">
  158. <span>{{ create.temp.tworate }}</span>
  159. <span>{{ create.temp.tworange }}</span>
  160. </el-form-item>
  161. </el-col>
  162. <el-col :span="8">
  163. <el-form-item label="第三层比例 (%):">
  164. <span>{{ create.temp.threerate }}</span>
  165. <span>{{ create.temp.threerange }}</span>
  166. </el-form-item>
  167. </el-col>
  168. </el-row>
  169. <el-row>
  170. <el-col :span="24">
  171. <h3 style="width: 150px;text-align: right;">操作详情</h3>
  172. </el-col>
  173. </el-row>
  174. <el-row>
  175. <el-col :span="8">
  176. <el-form-item label="操作人:" prop="emp">
  177. <el-select ref="emp" v-model="create.temp.emp" filterable placeholder="操作人" class="filter-item" style="width: 100%;" @blur="blurEmp">
  178. <el-option v-for="item in create.noteTakerList" :key="item.myId" :label="item.emp" :value="item.emp" />
  179. </el-select>
  180. </el-form-item>
  181. </el-col>
  182. <el-col :span="8">
  183. <el-form-item label="操作日期:" prop="operatetime">
  184. <el-date-picker v-model="create.temp.operatetime" :disabled="create.dialogStatus=='update'" type="date" placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width: 100%;" :clearable="false" @change="changeOperatetime" />
  185. </el-form-item>
  186. </el-col>
  187. <el-col :span="8">
  188. <el-form-item label="备注:" prop="remark">
  189. <el-input ref="remark" v-model="create.temp.remark" class="filter-item" placeholder="1-255字符" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" style="width: 100%;" />
  190. </el-form-item>
  191. </el-col>
  192. </el-row>
  193. </el-form>
  194. <div slot="footer" class="dialog-footer">
  195. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  196. <el-button v-if="create.dialogStatus==='create'" class="save" :disabled="isokDisable" @click="createDataAgain()">确认新增</el-button>
  197. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="save" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  198. </div>
  199. </div>
  200. </el-dialog>
  201. <!-- 历史记录 -->
  202. <el-dialog :fullscreen="dialogFull" :destroy-on-close="true" :visible.sync="historyRecord.dialogFormVisible" :close-on-click-modal="false" width="90%">
  203. <template slot="title">
  204. <div class="avue-crud__dialog__header">
  205. <span class="el-dialog__title">
  206. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  207. {{ textMap[historyRecord.dialogStatus] }}
  208. </span>
  209. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  210. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  211. <svg-icon v-else icon-class="fullscreen" />
  212. </div>
  213. </div>
  214. </template>
  215. <div class="historyRecord">
  216. <keep-alive>
  217. <component :is="historyRecord.myComponent" ref="historyRecord" />
  218. </keep-alive>
  219. <div slot="footer" class="dialog-footer">
  220. <el-button class="cancelClose cancelClose1" @click="historyRecord.dialogFormVisible = false; ">关闭</el-button>
  221. </div>
  222. </div>
  223. </el-dialog>
  224. </div>
  225. </template>
  226. <script>
  227. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames, checkButtons } from '@/api/common'
  228. import Cookies from 'js-cookie'
  229. import { parseTime, json2excel } from '@/utils/index.js'
  230. import Pagination from '@/components/Pagination'
  231. import { MessageBox } from 'element-ui'
  232. import axios from 'axios'
  233. import { getToken } from '@/utils/auth'
  234. export default {
  235. name: 'FecalScreen',
  236. components: { Pagination },
  237. data() {
  238. return {
  239. dialogFull: false,
  240. isRoleEdit: [],
  241. requestParams: [
  242. { name: 'getBarListEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid') }},
  243. { name: 'getSysoptEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid'), 'inforname': 'times' }}
  244. ],
  245. houseNameList: [], // 栏舍名称
  246. frequencyList: [], // 班次
  247. table: {
  248. getdataListParm: {
  249. name: 'getDungsieveList',
  250. page: 1,
  251. offset: 1,
  252. pagecount: parseInt(Cookies.get('pageCount')),
  253. returntype: 'Map',
  254. parammaps: {
  255. pastureid: Cookies.get('pastureid'),
  256. barid: '',
  257. times: '',
  258. startTime: '',
  259. stopTime: '',
  260. inputDatetime: ''
  261. }
  262. },
  263. tableKey: 0,
  264. list: [],
  265. total: 0,
  266. listLoading: true,
  267. temp: {}
  268. },
  269. // 新增/编辑
  270. create: {
  271. dialogFormVisible: false,
  272. dialogStatus: '',
  273. temp: { pastureid: Cookies.get('pastureid'), operatetime: parseTime(new Date(), '{y}-{m}-{d}'), emp: Cookies.get('employename'), barid: '', barname: '', times: '', oneweight: '', twoweight: '', threeweight: '', onerate: '', tworate: '', threerate: '', tworange: '', threerange: '', remark: '', ccid: '', ccname: '' },
  274. rules: {
  275. barid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  276. oneweight: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  277. twoweight: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  278. threeweight: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  279. },
  280. // 操作人
  281. getdataListParm: {
  282. name: 'getDungsieveEmpHis',
  283. page: 1,
  284. offset: 1,
  285. pagecount: 10,
  286. returntype: 'Map',
  287. parammaps: {
  288. pastureid: Cookies.get('pastureid')
  289. }
  290. },
  291. // 宾州筛范围
  292. getdataListParm2: {
  293. name: 'getDungsieveRange',
  294. page: 1,
  295. offset: 1,
  296. pagecount: 1,
  297. returntype: 'Map',
  298. parammaps: {
  299. pastureid: Cookies.get('pastureid'),
  300. barid: '',
  301. date: ''
  302. }
  303. },
  304. noteTakerList: [] // 记录人
  305. },
  306. textMap: {
  307. create: '新增',
  308. update: '编辑',
  309. historyRecord: '历史记录'
  310. },
  311. historyRecord: {
  312. dialogFormVisible: false,
  313. dialogStatus: '',
  314. myComponent: null
  315. },
  316. requestParam: {},
  317. requestParam2: {},
  318. download: {
  319. getdataListParm: {
  320. name: 'getDungsieveList',
  321. page: 1,
  322. offset: 1,
  323. pagecount: 0,
  324. returntype: 'Map',
  325. parammaps: {
  326. pastureid: Cookies.get('pastureid'),
  327. barid: '',
  328. times: '',
  329. startTime: '',
  330. stopTime: '',
  331. inputDatetime: ''
  332. }
  333. },
  334. list: []
  335. },
  336. isokDisable: false,
  337. selectList: [],
  338. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  339. cellStyle: { padding: 0 + 'px' }
  340. }
  341. },
  342. computed: {
  343. // 设置请求头
  344. headers() {
  345. return {
  346. token: getToken()
  347. }
  348. },
  349. uploadData() {
  350. return {
  351. name: 'checkbarname,insertDungsieveUpload',
  352. importParams: '栏舍名称,第一层重量(g),第二层重量(g),第三层重量(g),备注,操作人,操作日期',
  353. sheetname: 'Sheet1',
  354. // 登录牧场
  355. pastureid: Cookies.get('pastureid'),
  356. // 日期参数
  357. dateParams: '操作日期',
  358. // 必填参数
  359. requiredParams: '栏舍名称,第一层重量(g),第二层重量(g),第三层重量(g)',
  360. // 为数值的参数
  361. numParams: '第一层重量(g),第二层重量(g),第三层重量(g)'
  362. }
  363. },
  364. // 设置上传地址
  365. uploadExcelUrl() {
  366. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  367. }
  368. },
  369. created() {
  370. this.getList()
  371. this.getDownList()
  372. this.getButtons()
  373. },
  374. methods: {
  375. getButtons() {
  376. const Edit = 'FecalScreen'
  377. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  378. this.isRoleEdit = isRoleEdit
  379. },
  380. getDownList() {
  381. GetDataByNames(this.requestParams).then(response => {
  382. this.houseNameList = response.data.getBarListEnable.list
  383. if (response.data.getSysoptEnable.list !== null) {
  384. for (let i = 1; i <= response.data.getSysoptEnable.list[0].inforvalue; i++) {
  385. const obj = {}
  386. obj.id = String(i)
  387. if (i == 1) { obj.name = '第一班' } else if (i == 2) { obj.name = '第二班' } else if (i == 3) { obj.name = '第三班' } else if (i == 4) { obj.name = '第四班' }
  388. this.frequencyList.push(obj)
  389. }
  390. } else {
  391. this.frequencyList = []
  392. }
  393. })
  394. },
  395. handleBefore() {
  396. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  397. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  398. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  399. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  400. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  401. this.$forceUpdate()
  402. }
  403. },
  404. handleNext() {
  405. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  406. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  407. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  408. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  409. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  410. this.$forceUpdate()
  411. }
  412. },
  413. getList() {
  414. this.table.listLoading = true
  415. GetDataByName(this.table.getdataListParm).then(response => {
  416. console.log('table数据', response.data.list)
  417. if (response.data.list !== null) {
  418. this.table.list = response.data.list
  419. this.table.pageNum = response.data.pageNum
  420. this.table.pageSize = response.data.pageSize
  421. this.table.total = response.data.total
  422. } else {
  423. this.table.list = []
  424. }
  425. setTimeout(() => {
  426. this.table.listLoading = false
  427. }, 100)
  428. })
  429. },
  430. handleSearch() {
  431. console.log('点击了查询')
  432. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  433. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  434. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  435. } else {
  436. this.table.getdataListParm.parammaps.inputDatetime = ''
  437. this.table.getdataListParm.parammaps.startTime = ''
  438. this.table.getdataListParm.parammaps.stopTime = ''
  439. }
  440. this.table.getdataListParm.offset = 1
  441. this.getList()
  442. },
  443. handleRefresh() {
  444. console.log('点击了重置')
  445. this.table.getdataListParm.parammaps.barid = ''
  446. this.table.getdataListParm.parammaps.times = ''
  447. this.table.getdataListParm.parammaps.startTime = ''
  448. this.table.getdataListParm.parammaps.stopTime = ''
  449. this.table.getdataListParm.parammaps.inputDatetime = ''
  450. this.table.getdataListParm.offset = 1
  451. this.getList()
  452. },
  453. // 新增
  454. resetTemp() {
  455. this.create.temp = { pastureid: Cookies.get('pastureid'), operatetime: parseTime(new Date(), '{y}-{m}-{d}'), emp: Cookies.get('employename'), barid: '', barname: '', times: '', oneweight: '', twoweight: '', threeweight: '', onerate: '', tworate: '', threerate: '', tworange: '', threerange: '', remark: '', ccid: '', ccname: '' }
  456. },
  457. blurEmp(item) {
  458. this.create.temp.emp = item.target.value
  459. },
  460. // 栏舍名称
  461. changeBar(item) {
  462. this.create.temp.barname = this.houseNameList.find(obj => obj.id === item).bname
  463. this.getRange()
  464. },
  465. changeOperatetime() {
  466. this.getRange()
  467. },
  468. // 粪便筛范围
  469. getRange() {
  470. this.create.getdataListParm2.parammaps.date = this.create.temp.operatetime
  471. this.create.getdataListParm2.parammaps.barid = this.create.temp.barid
  472. GetDataByName(this.create.getdataListParm2).then(response => {
  473. if (response.data.list !== null) {
  474. this.create.temp.onerange = response.data.list[0].oneRange
  475. this.create.temp.tworange = response.data.list[0].twoRange
  476. this.create.temp.threerange = response.data.list[0].threeRange
  477. this.create.temp.ccid = response.data.list[0].ccid
  478. this.create.temp.ccname = response.data.list[0].ccname
  479. } else {
  480. this.create.temp.onerange = ''
  481. this.create.temp.tworange = ''
  482. this.create.temp.threerange = ''
  483. this.create.temp.ccid = ''
  484. this.create.temp.ccname = ''
  485. }
  486. })
  487. },
  488. // 操作人
  489. getNoteTakerList() {
  490. GetDataByName(this.create.getdataListParm).then(response => {
  491. if (response.data.list !== null) {
  492. for (let i = 0; i < response.data.list.length; i++) {
  493. response.data.list[i].myId = i
  494. }
  495. this.create.noteTakerList = response.data.list
  496. console.log('记录人数据', response.data.list)
  497. console.log(this.create.noteTakerList)
  498. } else {
  499. this.create.noteTakerList = []
  500. }
  501. })
  502. },
  503. blurWeight() {
  504. if (this.create.temp.oneweight && this.create.temp.twoweight && this.create.temp.threeweight) {
  505. const weightSum = parseFloat(this.create.temp.oneweight) + parseFloat(this.create.temp.twoweight) + parseFloat(this.create.temp.threeweight)
  506. this.create.temp.onerate = (parseFloat(this.create.temp.oneweight) / weightSum * 100).toFixed(2)
  507. this.create.temp.tworate = (parseFloat(this.create.temp.twoweight) / weightSum * 100).toFixed(2)
  508. this.create.temp.threerate = (100 - this.create.temp.onerate - this.create.temp.tworate).toFixed(2)
  509. }
  510. },
  511. handleCreate() {
  512. console.log('点击了新增')
  513. this.resetTemp()
  514. this.getNoteTakerList()
  515. this.dialogFull = false
  516. this.create.dialogStatus = 'create'
  517. this.create.dialogFormVisible = true
  518. },
  519. createData() {
  520. console.log('点击了新增保存')
  521. this.isokDisable = true
  522. setTimeout(() => {
  523. this.isokDisable = false
  524. }, 1000)
  525. this.$refs['temp'].validate(valid => {
  526. if (valid) {
  527. this.isokDisable = true
  528. setTimeout(() => {
  529. this.isokDisable = false
  530. }, 1000)
  531. const weight = /^\d+(\.\d{1,2})?$/
  532. // 第一层重量
  533. if (!weight.test(parseFloat(this.create.temp.oneweight)) || !weight.test(parseFloat(this.create.temp.twoweight)) || !weight.test(parseFloat(this.create.temp.threeweight))) {
  534. this.$message({ type: 'error', message: '重量不可小于0,最多保留俩位小数', duration: 2000 })
  535. return false
  536. }
  537. this.requestParam.name = 'insertDungsieve'
  538. this.requestParam.parammaps = this.create.temp
  539. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  540. PostDataByName(this.requestParam).then(response => {
  541. console.log('新增保存发送参数', this.requestParam)
  542. if (response.msg !== 'fail') {
  543. this.saveData()
  544. } else {
  545. const checkStr = new RegExp('Duplicate entry :pbto')
  546. if (checkStr.test(response.data)) {
  547. this.$notify({ title: '保存失败', message: '同一栏舍不可重复录入', type: 'warning', duration: 2000 })
  548. } else {
  549. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  550. }
  551. }
  552. })
  553. }
  554. })
  555. },
  556. saveData() {
  557. this.requestParam2.name = 'insertDungHistory'
  558. this.create.temp.pastureid = Cookies.get('pastureid')
  559. this.create.temp.changetime = parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}')
  560. this.create.temp.species = 'fps'
  561. this.create.temp.fourrate = ''
  562. this.create.temp.fourweight = ''
  563. this.requestParam2.parammaps = this.create.temp
  564. PostDataByName(this.requestParam2).then(response => {
  565. console.log('新增保存发送参数', this.requestParam1)
  566. if (response.msg !== 'fail') {
  567. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  568. this.create.dialogFormVisible = false
  569. this.getList()
  570. } else {
  571. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  572. }
  573. })
  574. },
  575. createDataAgain() {
  576. console.log('点击了新增保存')
  577. this.isokDisable = true
  578. setTimeout(() => {
  579. this.isokDisable = false
  580. }, 1000)
  581. this.$refs['temp'].validate(valid => {
  582. if (valid) {
  583. this.isokDisable = true
  584. setTimeout(() => {
  585. this.isokDisable = false
  586. }, 1000)
  587. const weight = /^\d+(\.\d{1,2})?$/
  588. // 第一层重量
  589. if (!weight.test(parseFloat(this.create.temp.oneweight)) || !weight.test(parseFloat(this.create.temp.twoweight)) || !weight.test(parseFloat(this.create.temp.threeweight))) {
  590. this.$message({ type: 'error', message: '重量不可小于0,最多保留俩位小数', duration: 2000 })
  591. return false
  592. }
  593. this.requestParam.name = 'insertDungsieve'
  594. this.requestParam.parammaps = this.create.temp
  595. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  596. PostDataByName(this.requestParam).then(response => {
  597. console.log('新增保存发送参数', this.requestParam)
  598. if (response.msg !== 'fail') {
  599. this.saveData()
  600. this.resetTemp()
  601. this.getList()
  602. this.getNoteTakerList()
  603. } else {
  604. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  605. }
  606. })
  607. }
  608. })
  609. },
  610. // 编辑
  611. handleUpdate(row) {
  612. console.log('点击了编辑', row)
  613. row.barid = String(row.barid)
  614. this.create.temp = Object.assign({}, row)
  615. this.create.temp.id = row.id
  616. this.getNoteTakerList()
  617. this.dialogFull = false
  618. this.create.dialogStatus = 'update'
  619. this.create.dialogFormVisible = true
  620. },
  621. updateData() {
  622. this.isokDisable = true
  623. setTimeout(() => {
  624. this.isokDisable = false
  625. }, 1000)
  626. this.$refs['temp'].validate(valid => {
  627. if (valid) {
  628. this.isokDisable = true
  629. setTimeout(() => {
  630. this.isokDisable = false
  631. }, 1000)
  632. const weight = /^\d+(\.\d{1,2})?$/
  633. // 第一层重量
  634. if (!weight.test(parseFloat(this.create.temp.oneweight)) || !weight.test(parseFloat(this.create.temp.twoweight)) || !weight.test(parseFloat(this.create.temp.threeweight))) {
  635. this.$message({ type: 'error', message: '重量不可小于0,最多保留俩位小数', duration: 2000 })
  636. return false
  637. }
  638. this.requestParam.name = 'updateDungsieve'
  639. this.requestParam.parammaps = this.create.temp
  640. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  641. PostDataByName(this.requestParam).then(response => {
  642. console.log('新增保存发送参数', this.requestParam)
  643. if (response.msg !== 'fail') {
  644. this.saveData()
  645. this.getList()
  646. } else {
  647. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  648. }
  649. })
  650. }
  651. })
  652. },
  653. // 删除
  654. handleRowDelete(row) {
  655. console.log('点击了行内删除')
  656. MessageBox.confirm('是否确认删除此信息?', {
  657. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  658. }).then(() => {
  659. this.selectList = []
  660. this.requestParam.name = 'deleteDungsieve'
  661. this.requestParam.parammaps = {}
  662. this.requestParam.parammaps.pastureid = row.pastureid
  663. this.requestParam.parammaps.id = row.id
  664. PostDataByName(this.requestParam).then(response => {
  665. if (response.msg === 'fail') {
  666. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  667. } else {
  668. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  669. this.getList()
  670. }
  671. })
  672. }).catch(() => {
  673. this.$message({ type: 'info', message: '已取消删除' })
  674. })
  675. },
  676. handleSelectionChange(val) {
  677. console.log('勾选数据', val)
  678. this.selectList = val
  679. },
  680. handleDelete() {
  681. console.log('点击了删除')
  682. if (this.selectList.length == 0) {
  683. this.$message({ type: 'error', message: '请选择粪便筛', duration: 2000 })
  684. } else {
  685. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  686. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  687. }).then(() => {
  688. console.log(this.selectList)
  689. this.requestParam.common = { 'returnmap': '0' }
  690. this.requestParam.data = []
  691. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  692. this.requestParam.data[0].children = []
  693. this.requestParam.data[0].children[0] = { 'name': 'deleteDungsieve', 'type': 'e', 'parammaps': {
  694. id: '@insertSpotList.id',
  695. pastureid: '@insertSpotList.pastureid'
  696. }}
  697. ExecDataByConfig(this.requestParam).then(response => {
  698. console.log('删除保存发送参数', this.requestParam)
  699. if (response.msg === 'fail') {
  700. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  701. } else {
  702. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  703. this.getList()
  704. }
  705. })
  706. })
  707. }
  708. },
  709. // 复制
  710. handleCopy() {
  711. console.log('点击了复制')
  712. if (this.selectList.length == 0) {
  713. this.$message({ type: 'error', message: '请选择粪便筛', duration: 2000 })
  714. } else if (this.selectList.length == 1) {
  715. MessageBox.confirm('是否确认复制此信息?', {
  716. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  717. }).then(() => {
  718. this.requestParam.name = 'copyDungsieve'
  719. this.requestParam.parammaps = {}
  720. this.requestParam.parammaps.pastureid = this.selectList[0].pastureid
  721. this.requestParam.parammaps.id = this.selectList[0].id
  722. PostDataByName(this.requestParam).then(response => {
  723. if (response.msg === 'fail') {
  724. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  725. } else {
  726. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  727. this.getList()
  728. }
  729. })
  730. }).catch(() => {
  731. this.$message({ type: 'info', message: '已取消删除' })
  732. })
  733. } else {
  734. this.$message({ type: 'error', message: '请选择一条粪便筛', duration: 2000 })
  735. }
  736. },
  737. // 导出
  738. handleExport(item) {
  739. if (item == 1) {
  740. console.log('点击了导出模板')
  741. const requestParam = this.requestParam
  742. const url = process.env.VUE_APP_BASE_API + 'file/导入导出模板/栏舍生产/粪便筛导入模板.xlsx' // 请求下载文件的地址
  743. console.log(url)
  744. axios({
  745. method: 'GET',
  746. url: url,
  747. data: requestParam,
  748. headers: { token: getToken(), optname: 'insertcustomdoc' },
  749. responseType: 'blob'
  750. }).then(res => {
  751. if (!res) return
  752. this.percentage = 99
  753. setTimeout(() => {
  754. this.isPercentage = false
  755. }, 2000)
  756. const blob = new Blob([res.data], {
  757. type: 'application/octet-stream;charset=utf-8'
  758. })
  759. const url = window.URL.createObjectURL(blob)
  760. const aLink = document.createElement('a')
  761. aLink.style.display = 'none'
  762. aLink.href = url
  763. const docname = '粪便筛导入模板.xlsx'
  764. aLink.setAttribute('download', docname) // 下载的文件
  765. document.body.appendChild(aLink)
  766. aLink.click()
  767. document.body.removeChild(aLink)
  768. window.URL.revokeObjectURL(url)
  769. })
  770. } else {
  771. console.log('点击了导出数据')
  772. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  773. if (this.download.getdataListParm.parammaps.inputDatetime !== '' && this.download.getdataListParm.parammaps.inputDatetime !== null) {
  774. this.download.getdataListParm.parammaps.startTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  775. this.download.getdataListParm.parammaps.stopTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  776. } else {
  777. this.download.getdataListParm.parammaps.inputDatetime = ''
  778. this.download.getdataListParm.parammaps.startTime = ''
  779. this.download.getdataListParm.parammaps.stopTime = ''
  780. }
  781. GetDataByName(this.download.getdataListParm).then(response => {
  782. if (response.data.list !== null) {
  783. this.download.list = response.data.list
  784. } else {
  785. this.download.list = []
  786. }
  787. var excelDatas = [
  788. {
  789. tHeader: ['栏舍名称', '第一层比例(%)', '第一层重量(g)', '第二层比例(%)', '第二层重量(g)', '第三层比例(%)', '第三层重量(g)', '备注', '操作人', '操作日期'],
  790. filterVal: ['barname', 'onerate', 'oneweight', 'tworate', 'twoweight', 'threerate', 'threeweight', 'remark', 'emp', 'operatetime'],
  791. tableDatas: this.download.list,
  792. sheetName: 'Sheet1'
  793. }
  794. ]
  795. json2excel(excelDatas, '粪便筛', true, 'xlsx')
  796. })
  797. }
  798. },
  799. beforeImport(file) {
  800. const isLt2M = file.size / 1024 / 1024 < 2
  801. if (!isLt2M) {
  802. this.$message.error('上传文件大小不能超过 2MB!')
  803. }
  804. return isLt2M
  805. },
  806. handleImportSuccess(res, file) {
  807. this.getList()
  808. if (res.msg === 'ok') {
  809. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  810. if (res.data.err_count > 0) {
  811. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  812. import('@/vendor/Export2Excel').then(excel => {
  813. const list1 = res.data.result
  814. const tHeader = [
  815. '栏舍名称', '第一层重量(g)', '第二层重量(g)', '第三层重量(g)', '备注', '操作人', '操作日期', '错误信息'
  816. ]
  817. const filterVal = [
  818. '栏舍名称', '第一层重量(g)', '第二层重量(g)', '第三层重量(g)', '备注', '操作人', '操作日期', 'error_msg'
  819. ]
  820. const data1 = this.formatJson(filterVal, list1)
  821. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '粪便筛导入报错信息', autoWidth: true, bookType: 'xlsx' })
  822. })
  823. }
  824. } else {
  825. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  826. }
  827. },
  828. formatJson(filterVal, jsonData) {
  829. return jsonData.map(v =>
  830. filterVal.map(j => {
  831. if (j === 'timestamp') {
  832. return parseTime(v[j])
  833. } else {
  834. return v[j]
  835. }
  836. })
  837. )
  838. },
  839. handleHistoryRecord() {
  840. console.log('点击历史记录')
  841. this.dialogFull = false
  842. this.historyRecord.dialogStatus = 'historyRecord'
  843. this.historyRecord.dialogFormVisible = true
  844. const vue = this
  845. var myComponent = () => import('./historyRecord.vue')
  846. return vue.historyRecord.myComponent = myComponent
  847. }
  848. }
  849. }
  850. </script>
  851. <style lang="scss" scoped>
  852. .search{padding-top:10px;clear: both;}
  853. .table{margin-top:10px;}
  854. </style>