index.vue 39 KB

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