dbb6af799edc76554746165bee82c605835b0d3f.svn-base 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  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. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  517. }
  518. })
  519. }
  520. })
  521. },
  522. createDataAgain() {
  523. console.log('点击了新增保存')
  524. this.isokDisable = true
  525. setTimeout(() => {
  526. this.isokDisable = false
  527. }, 1000)
  528. this.$refs['temp'].validate(valid => {
  529. if (valid) {
  530. this.isokDisable = true
  531. setTimeout(() => {
  532. this.isokDisable = false
  533. }, 1000)
  534. const weight = /^\d+(\.\d{1,2})?$/
  535. // 第一层重量
  536. if (!weight.test(parseFloat(this.create.temp.oneweight)) || !weight.test(parseFloat(this.create.temp.twoweight)) || !weight.test(parseFloat(this.create.temp.threeweight))) {
  537. this.$message({ type: 'error', message: '重量不可小于0,最多保留俩位小数', duration: 2000 })
  538. return false
  539. }
  540. this.requestParam.name = 'insertDungsieve'
  541. this.requestParam.parammaps = this.create.temp
  542. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  543. PostDataByName(this.requestParam).then(response => {
  544. console.log('新增保存发送参数', this.requestParam)
  545. if (response.msg !== 'fail') {
  546. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  547. this.resetTemp()
  548. this.getList()
  549. this.getNoteTakerList()
  550. } else {
  551. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  552. }
  553. })
  554. }
  555. })
  556. },
  557. // 编辑
  558. handleUpdate(row) {
  559. console.log('点击了编辑', row)
  560. row.barid = String(row.barid)
  561. this.create.temp = Object.assign({}, row)
  562. this.create.temp.id = row.id
  563. this.getNoteTakerList()
  564. this.dialogFull = false
  565. this.create.dialogStatus = 'update'
  566. this.create.dialogFormVisible = true
  567. },
  568. updateData() {
  569. this.isokDisable = true
  570. setTimeout(() => {
  571. this.isokDisable = false
  572. }, 1000)
  573. this.$refs['temp'].validate(valid => {
  574. if (valid) {
  575. this.isokDisable = true
  576. setTimeout(() => {
  577. this.isokDisable = false
  578. }, 1000)
  579. const weight = /^\d+(\.\d{1,2})?$/
  580. // 第一层重量
  581. if (!weight.test(parseFloat(this.create.temp.oneweight)) || !weight.test(parseFloat(this.create.temp.twoweight)) || !weight.test(parseFloat(this.create.temp.threeweight))) {
  582. this.$message({ type: 'error', message: '重量不可小于0,最多保留俩位小数', duration: 2000 })
  583. return false
  584. }
  585. this.requestParam.name = 'updateDungsieve'
  586. this.requestParam.parammaps = this.create.temp
  587. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  588. PostDataByName(this.requestParam).then(response => {
  589. console.log('新增保存发送参数', this.requestParam)
  590. if (response.msg !== 'fail') {
  591. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  592. this.create.dialogFormVisible = false
  593. this.getList()
  594. } else {
  595. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  596. }
  597. })
  598. }
  599. })
  600. },
  601. // 删除
  602. handleRowDelete(row) {
  603. console.log('点击了行内删除')
  604. MessageBox.confirm('是否确认删除此信息?', {
  605. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  606. }).then(() => {
  607. this.selectList = []
  608. this.requestParam.name = 'deleteDungsieve'
  609. this.requestParam.parammaps = {}
  610. this.requestParam.parammaps.pastureid = row.pastureid
  611. this.requestParam.parammaps.id = row.id
  612. PostDataByName(this.requestParam).then(response => {
  613. if (response.msg === 'fail') {
  614. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  615. } else {
  616. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  617. this.getList()
  618. }
  619. })
  620. }).catch(() => {
  621. this.$message({ type: 'info', message: '已取消删除' })
  622. })
  623. },
  624. handleSelectionChange(val) {
  625. console.log('勾选数据', val)
  626. this.selectList = val
  627. },
  628. handleDelete() {
  629. console.log('点击了删除')
  630. if (this.selectList.length == 0) {
  631. this.$message({ type: 'error', message: '请选择粪便筛', duration: 2000 })
  632. } else {
  633. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  634. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  635. }).then(() => {
  636. console.log(this.selectList)
  637. this.requestParam.common = { 'returnmap': '0' }
  638. this.requestParam.data = []
  639. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  640. this.requestParam.data[0].children = []
  641. this.requestParam.data[0].children[0] = { 'name': 'deleteDungsieve', 'type': 'e', 'parammaps': {
  642. id: '@insertSpotList.id',
  643. pastureid: '@insertSpotList.pastureid'
  644. }}
  645. ExecDataByConfig(this.requestParam).then(response => {
  646. console.log('删除保存发送参数', this.requestParam)
  647. if (response.msg === 'fail') {
  648. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  649. } else {
  650. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  651. this.getList()
  652. }
  653. })
  654. })
  655. }
  656. },
  657. // 复制
  658. handleCopy() {
  659. console.log('点击了复制')
  660. if (this.selectList.length == 0) {
  661. this.$message({ type: 'error', message: '请选择粪便筛', duration: 2000 })
  662. } else if (this.selectList.length == 1) {
  663. MessageBox.confirm('是否确认复制此信息?', {
  664. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  665. }).then(() => {
  666. this.requestParam.name = 'copyDungsieve'
  667. this.requestParam.parammaps = {}
  668. this.requestParam.parammaps.pastureid = this.selectList[0].pastureid
  669. this.requestParam.parammaps.id = this.selectList[0].id
  670. PostDataByName(this.requestParam).then(response => {
  671. if (response.msg === 'fail') {
  672. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  673. } else {
  674. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  675. this.getList()
  676. }
  677. })
  678. }).catch(() => {
  679. this.$message({ type: 'info', message: '已取消删除' })
  680. })
  681. } else {
  682. this.$message({ type: 'error', message: '请选择一条粪便筛', duration: 2000 })
  683. }
  684. },
  685. // 导出
  686. handleExport(item) {
  687. if (item == 1) {
  688. console.log('点击了导出模板')
  689. const requestParam = this.requestParam
  690. const url = process.env.VUE_APP_BASE_API + 'file/导入导出模板/栏舍生产/粪便筛导入模板.xlsx' // 请求下载文件的地址
  691. console.log(url)
  692. axios({
  693. method: 'GET',
  694. url: url,
  695. data: requestParam,
  696. headers: { token: getToken(), optname: 'insertcustomdoc' },
  697. responseType: 'blob'
  698. }).then(res => {
  699. if (!res) return
  700. this.percentage = 99
  701. setTimeout(() => {
  702. this.isPercentage = false
  703. }, 2000)
  704. const blob = new Blob([res.data], {
  705. type: 'application/octet-stream;charset=utf-8'
  706. })
  707. const url = window.URL.createObjectURL(blob)
  708. const aLink = document.createElement('a')
  709. aLink.style.display = 'none'
  710. aLink.href = url
  711. const docname = '粪便筛导入模板.xlsx'
  712. aLink.setAttribute('download', docname) // 下载的文件
  713. document.body.appendChild(aLink)
  714. aLink.click()
  715. document.body.removeChild(aLink)
  716. window.URL.revokeObjectURL(url)
  717. })
  718. } else {
  719. console.log('点击了导出数据')
  720. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  721. if (this.download.getdataListParm.parammaps.inputDatetime !== '' && this.download.getdataListParm.parammaps.inputDatetime !== null) {
  722. this.download.getdataListParm.parammaps.startTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  723. this.download.getdataListParm.parammaps.stopTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  724. } else {
  725. this.download.getdataListParm.parammaps.inputDatetime = ''
  726. this.download.getdataListParm.parammaps.startTime = ''
  727. this.download.getdataListParm.parammaps.stopTime = ''
  728. }
  729. GetDataByName(this.download.getdataListParm).then(response => {
  730. if (response.data.list !== null) {
  731. this.download.list = response.data.list
  732. } else {
  733. this.download.list = []
  734. }
  735. var excelDatas = [
  736. {
  737. tHeader: ['栏舍名称', '第一层比例(%)', '第一层重量(g)', '第二层比例(%)', '第二层重量(g)', '第三层比例(%)', '第三层重量(g)', '备注', '操作人', '操作日期'],
  738. filterVal: ['barname', 'onerate', 'oneweight', 'tworate', 'twoweight', 'threerate', 'threeweight', 'remark', 'emp', 'operatetime'],
  739. tableDatas: this.download.list,
  740. sheetName: 'Sheet1'
  741. }
  742. ]
  743. json2excel(excelDatas, '粪便筛', true, 'xlsx')
  744. })
  745. }
  746. },
  747. beforeImport(file) {
  748. const isLt2M = file.size / 1024 / 1024 < 2
  749. if (!isLt2M) {
  750. this.$message.error('上传文件大小不能超过 2MB!')
  751. }
  752. return isLt2M
  753. },
  754. handleImportSuccess(res, file) {
  755. this.getList()
  756. if (res.msg === 'ok') {
  757. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  758. if (res.data.err_count > 0) {
  759. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  760. import('@/vendor/Export2Excel').then(excel => {
  761. const list1 = res.data.result
  762. const tHeader = [
  763. '栏舍名称', '第一层重量(g)', '第二层重量(g)', '第三层重量(g)', '备注', '操作人', '操作日期', '错误信息'
  764. ]
  765. const filterVal = [
  766. '栏舍名称', '第一层重量(g)', '第二层重量(g)', '第三层重量(g)', '备注', '操作人', '操作日期', 'error_msg'
  767. ]
  768. const data1 = this.formatJson(filterVal, list1)
  769. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '粪便筛导入报错信息', autoWidth: true, bookType: 'xlsx' })
  770. })
  771. }
  772. } else {
  773. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  774. }
  775. },
  776. formatJson(filterVal, jsonData) {
  777. return jsonData.map(v =>
  778. filterVal.map(j => {
  779. if (j === 'timestamp') {
  780. return parseTime(v[j])
  781. } else {
  782. return v[j]
  783. }
  784. })
  785. )
  786. }
  787. }
  788. }
  789. </script>
  790. <style lang="scss" scoped>
  791. .search{padding-top:10px;clear: both;}
  792. .table{margin-top:10px;}
  793. </style>