074b61f78545778ffb6ae58442263e62b2a7e448.svn-base 36 KB

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