b57dd6b58aada08c8ee81eea76ee0a2a84924e7b.svn-base 36 KB

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