85353f7eb2205463a65f7077ad2f3561695ef5d4.svn-base 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button class="success" style="float: left;margin-right:10px;" @click="handleCreate">新增</el-button>
  5. <el-button class="danger" style="float: left;margin-right:10px;" @click="handleDelete">删除</el-button>
  6. <el-button class="warning" style="float: left;margin-right:10px;" @click="handleCopy">复制</el-button>
  7. <el-button class="import" style="float: right;" @click="handleImport">导入</el-button>
  8. <el-button class="export" style="float: right;margin-right: 10px;" @click="handleExport">导出</el-button>
  9. </div>
  10. <div class="search">
  11. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
  12. <el-select v-model="table.getdataListParm.parammaps.barid" placeholder="栏舍名称" class="filter-item" style="width: 120px;" clearable>
  13. <el-option v-for="item in houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  14. </el-select>
  15. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  16. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  17. </div>
  18. <div class="table">
  19. <el-table
  20. :key="table.tableKey"
  21. v-loading="table.listLoading"
  22. element-loading-text="给我一点时间"
  23. :data="table.list"
  24. border
  25. fit
  26. highlight-current-row
  27. style="width: 100%;"
  28. :row-style="rowStyle"
  29. :cell-style="cellStyle"
  30. class="elTable table-fixed"
  31. @selection-change="handleSelectionChange"
  32. >
  33. <el-table-column type="selection" align="center" width="50" />
  34. <el-table-column label="序号" align="center" type="index" width="50px">
  35. <template slot-scope="scope">
  36. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="栏舍名称" min-width="150px" align="center">
  40. <template slot-scope="scope">
  41. <span>{{ scope.row.barname }}</span>
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="剩料量(kg)" min-width="150px" align="center">
  45. <template slot-scope="scope">
  46. <span>{{ scope.row.remain }}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="班次" min-width="90px" align="center">
  50. <template slot-scope="scope">
  51. <span>{{ scope.row.times }}</span>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="处理时间" min-width="100px" align="center">
  55. <template slot-scope="scope">
  56. <span>{{ scope.row.operatetime }}</span>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="操作人" min-width="90px" align="center">
  60. <template slot-scope="scope">
  61. <span>{{ scope.row.emp }}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  65. <template slot-scope="{row}">
  66. <el-button class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  67. <el-button class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  68. </template>
  69. </el-table-column>
  70. </el-table>
  71. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  72. </div>
  73. <!-- 新增/编辑 -->
  74. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="40%">
  75. <div class="app-add">
  76. <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="135px" style="width: 90%;margin:0 auto 50px">
  77. <el-row>
  78. <el-col :span="20">
  79. <el-form-item label="栏舍名称:" prop="barid">
  80. <el-select ref="barid" v-model="create.temp.barid" filterable placeholder="栏舍名称" class="filter-item" style="width: 100%;" @change="changeBar">
  81. <el-option v-for="item in houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  82. </el-select>
  83. </el-form-item>
  84. </el-col>
  85. </el-row>
  86. <el-row>
  87. <el-col :span="20">
  88. <el-form-item label="剩料量:" prop="remain">
  89. <el-input ref="remain" v-model="create.temp.remain" class="filter-item" placeholder="剩料量" type="number" />
  90. </el-form-item>
  91. </el-col>
  92. </el-row>
  93. <el-row>
  94. <el-col :span="20">
  95. <el-form-item label="班次:" prop="times">
  96. <el-select ref="times" v-model="create.temp.times" filterable placeholder="班次" class="filter-item" style="width: 100%;">
  97. <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  98. </el-select>
  99. </el-form-item>
  100. </el-col>
  101. </el-row>
  102. <el-row>
  103. <el-col :span="20">
  104. <el-form-item label="操作时间:" prop="operatetime">
  105. <el-date-picker v-model="create.temp.operatetime" type="datetime" placeholder="选择日期" format="yyyy-MM-dd HH:mm" value-format="yyyy-MM-dd HH:mm" style="width: 100%;" :clearable="false" />
  106. </el-form-item>
  107. </el-col>
  108. </el-row>
  109. <el-row>
  110. <el-col :span="20">
  111. <el-form-item label="操作人:" prop="emp">
  112. <el-select ref="emp" v-model="create.temp.emp" filterable placeholder="操作人" class="filter-item" style="width: 100%;" @blur="blurEmp">
  113. <el-option v-for="item in create.noteTakerList" :key="item.myId" :label="item.emp" :value="item.emp" />
  114. </el-select>
  115. </el-form-item>
  116. </el-col>
  117. </el-row>
  118. </el-form>
  119. <div slot="footer" class="dialog-footer">
  120. <el-button class="cancel" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  121. <el-button v-if="create.dialogStatus==='create'" class="success" :disabled="isokDisable" @click="createDataAgain()">确认新增</el-button>
  122. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="success" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  123. </div>
  124. </div>
  125. </el-dialog>
  126. </div>
  127. </template>
  128. <script>
  129. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames } from '@/api/common'
  130. import Cookies from 'js-cookie'
  131. import { parseTime } from '@/utils/index.js'
  132. import Pagination from '@/components/Pagination'
  133. import { MessageBox } from 'element-ui'
  134. export default {
  135. name: 'MaterialRemainingRecord',
  136. components: { Pagination },
  137. data() {
  138. return {
  139. requestParams: [
  140. { name: 'getBarListEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid') }},
  141. { name: 'getSysoptEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid'), 'inforname': 'times' }}
  142. ],
  143. houseNameList: [], // 栏舍名称
  144. frequencyList: [], // 班次
  145. table: {
  146. getdataListParm: {
  147. name: 'getBarfeedremainList',
  148. page: 1,
  149. offset: 1,
  150. pagecount: 10,
  151. returntype: 'Map',
  152. parammaps: {
  153. pastureid: Cookies.get('pastureid'),
  154. barid: '',
  155. startTime: '',
  156. stopTime: '',
  157. inputDatetime: ''
  158. }
  159. },
  160. tableKey: 0,
  161. list: [],
  162. total: 0,
  163. listLoading: true,
  164. temp: {}
  165. },
  166. // 新增/编辑
  167. create: {
  168. dialogFormVisible: false,
  169. dialogStatus: '',
  170. temp: { pastureid: Cookies.get('pastureid'), operatetime: parseTime(new Date(), '{y}-{m}-{d} {h}:{m}'), emp: Cookies.get('employename'), barid: '', barname: '', remain: '', times: '' },
  171. rules: {
  172. barid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  173. remain: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  174. times: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  175. },
  176. getdataListParm: {
  177. name: 'getBarfeedremainEmpHis',
  178. page: 1,
  179. offset: 1,
  180. pagecount: 10,
  181. returntype: 'Map',
  182. parammaps: {
  183. pastureid: Cookies.get('pastureid')
  184. }
  185. },
  186. noteTakerList: [] // 记录人
  187. },
  188. textMap: {
  189. create: '新增',
  190. update: '编辑'
  191. },
  192. requestParam: {},
  193. isokDisable: false,
  194. selectList: [],
  195. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  196. cellStyle: { padding: 0 + 'px' }
  197. }
  198. },
  199. created() {
  200. this.getList()
  201. this.getDownList()
  202. },
  203. methods: {
  204. getDownList() {
  205. GetDataByNames(this.requestParams).then(response => {
  206. this.houseNameList = response.data.getBarListEnable.list
  207. if (response.data.getSysoptEnable.list !== null) {
  208. for (let i = 1; i <= response.data.getSysoptEnable.list[0].inforvalue; i++) {
  209. const obj = {}
  210. obj.id = String(i)
  211. if (i == 1) { obj.name = '第一班' } else if (i == 2) { obj.name = '第二班' } else if (i == 3) { obj.name = '第三班' } else if (i == 4) { obj.name = '第四班' }
  212. this.frequencyList.push(obj)
  213. }
  214. } else {
  215. this.frequencyList = []
  216. }
  217. })
  218. },
  219. getList() {
  220. this.table.listLoading = true
  221. GetDataByName(this.table.getdataListParm).then(response => {
  222. console.log('table数据', response.data.list)
  223. if (response.data.list !== null) {
  224. this.table.list = response.data.list
  225. this.table.pageNum = response.data.pageNum
  226. this.table.pageSize = response.data.pageSize
  227. this.table.total = response.data.total
  228. } else {
  229. this.table.list = []
  230. }
  231. setTimeout(() => {
  232. this.table.listLoading = false
  233. }, 100)
  234. })
  235. },
  236. handleSearch() {
  237. console.log('点击了查询')
  238. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  239. this.table.getdataListParm.parammaps.starTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  240. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  241. } else {
  242. this.table.getdataListParm.parammaps.inputDatetime = ''
  243. this.table.getdataListParm.parammaps.starTime = ''
  244. this.table.getdataListParm.parammaps.stopTime = ''
  245. }
  246. this.table.getdataListParm.offset = 1
  247. this.getList()
  248. },
  249. handleRefresh() {
  250. console.log('点击了重置')
  251. this.table.getdataListParm.parammaps.barid = ''
  252. this.table.getdataListParm.parammaps.startTime = ''
  253. this.table.getdataListParm.parammaps.stopTime = ''
  254. this.table.getdataListParm.parammaps.inputDatetime = ''
  255. this.table.getdataListParm.offset = 1
  256. this.getList()
  257. },
  258. // 新增
  259. resetTemp() {
  260. this.create.temp = { pastureid: Cookies.get('pastureid'), operatetime: parseTime(new Date(), '{y}-{m}-{d} {h}:{m}'), emp: Cookies.get('employename'), barid: '', barname: '', remain: '', times: '' }
  261. },
  262. blurEmp(item) {
  263. this.create.temp.emp = item.target.value
  264. },
  265. // 栏舍名称
  266. changeBar(item) {
  267. this.create.temp.barname = this.houseNameList.find(obj => obj.id === item).bname
  268. },
  269. getNoteTakerList() {
  270. GetDataByName(this.create.getdataListParm).then(response => {
  271. if (response.data.list !== null) {
  272. for (let i = 0; i < response.data.list.length; i++) {
  273. response.data.list[i].myId = i
  274. }
  275. this.create.noteTakerList = response.data.list
  276. console.log('记录人数据', response.data.list)
  277. console.log(this.create.noteTakerList)
  278. } else {
  279. this.create.noteTakerList = []
  280. }
  281. })
  282. },
  283. handleCreate() {
  284. console.log('点击了新增')
  285. this.resetTemp()
  286. this.getNoteTakerList()
  287. this.create.dialogStatus = 'create'
  288. this.create.dialogFormVisible = true
  289. },
  290. createData() {
  291. console.log('点击了新增保存')
  292. this.isokDisable = true
  293. setTimeout(() => {
  294. this.isokDisable = false
  295. }, 1000)
  296. this.$refs['temp'].validate(valid => {
  297. if (valid) {
  298. this.isokDisable = true
  299. setTimeout(() => {
  300. this.isokDisable = false
  301. }, 1000)
  302. const remain = /^\d+(\.\d{1,2})?$/
  303. // 剩料量
  304. if (!remain.test(parseFloat(this.create.temp.remain))) {
  305. this.$message({ type: 'error', message: '剩料量请输入自然数并保留两位小数', duration: 2000 })
  306. return false
  307. }
  308. this.requestParam.name = 'insertBarfeedremain'
  309. this.requestParam.parammaps = this.create.temp
  310. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  311. PostDataByName(this.requestParam).then(response => {
  312. console.log('新增保存发送参数', this.requestParam)
  313. if (response.msg !== 'fail') {
  314. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  315. this.create.dialogFormVisible = false
  316. this.getList()
  317. } else {
  318. if (response.data.indexOf('barid')) {
  319. this.$message({ type: 'error', message: '该栏舍今日剩料记录已存在,不可重复生成', duration: 2000 })
  320. } else {
  321. failproccess(response, this.$notify)
  322. }
  323. }
  324. })
  325. }
  326. })
  327. },
  328. createDataAgain() {
  329. console.log('点击了新增保存')
  330. this.isokDisable = true
  331. setTimeout(() => {
  332. this.isokDisable = false
  333. }, 1000)
  334. this.$refs['temp'].validate(valid => {
  335. if (valid) {
  336. this.isokDisable = true
  337. setTimeout(() => {
  338. this.isokDisable = false
  339. }, 1000)
  340. const remain = /^\d+(\.\d{1,2})?$/
  341. // 剩料量
  342. if (!remain.test(parseFloat(this.create.temp.remain))) {
  343. this.$message({ type: 'error', message: '剩料量请输入自然数并保留两位小数', duration: 2000 })
  344. return false
  345. }
  346. this.requestParam.name = 'insertBarfeedremain'
  347. this.requestParam.parammaps = this.create.temp
  348. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  349. PostDataByName(this.requestParam).then(response => {
  350. console.log('新增保存发送参数', this.requestParam)
  351. if (response.msg !== 'fail') {
  352. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  353. this.resetTemp()
  354. this.getList()
  355. this.getNoteTakerList()
  356. } else {
  357. if (response.data.indexOf('barid')) {
  358. this.$message({ type: 'error', message: '该栏舍今日剩料记录已存在,不可重复生成', duration: 2000 })
  359. } else {
  360. failproccess(response, this.$notify)
  361. }
  362. }
  363. })
  364. }
  365. })
  366. },
  367. // 编辑
  368. handleUpdate(row) {
  369. console.log('点击了编辑', row)
  370. row.barid = String(row.barid)
  371. this.create.temp = Object.assign({}, row)
  372. this.create.temp.id = row.id
  373. this.getNoteTakerList()
  374. this.create.dialogStatus = 'update'
  375. this.create.dialogFormVisible = true
  376. },
  377. updateData() {
  378. this.isokDisable = true
  379. setTimeout(() => {
  380. this.isokDisable = false
  381. }, 1000)
  382. this.$refs['temp'].validate(valid => {
  383. if (valid) {
  384. this.isokDisable = true
  385. setTimeout(() => {
  386. this.isokDisable = false
  387. }, 1000)
  388. const remain = /^\d+(\.\d{1,2})?$/
  389. // 剩料量
  390. if (!remain.test(parseFloat(this.create.temp.remain))) {
  391. this.$message({ type: 'error', message: '剩料量请输入自然数并保留两位小数', duration: 2000 })
  392. return false
  393. }
  394. this.requestParam.name = 'updateBarfeedremain'
  395. this.requestParam.parammaps = this.create.temp
  396. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  397. PostDataByName(this.requestParam).then(response => {
  398. console.log('新增保存发送参数', this.requestParam)
  399. if (response.msg !== 'fail') {
  400. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  401. this.create.dialogFormVisible = false
  402. this.getList()
  403. } else {
  404. failproccess(response, this.$notify)
  405. }
  406. })
  407. }
  408. })
  409. },
  410. // 删除
  411. handleRowDelete(row) {
  412. console.log('点击了行内删除')
  413. MessageBox.confirm('是否确认删除此信息?', {
  414. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  415. }).then(() => {
  416. this.requestParam.name = 'deleteBarfeedremain'
  417. this.requestParam.parammaps = {}
  418. this.requestParam.parammaps.pastureid = row.pastureid
  419. this.requestParam.parammaps.id = row.id
  420. PostDataByName(this.requestParam).then(response => {
  421. if (response.msg === 'fail') {
  422. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  423. } else {
  424. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  425. this.getList()
  426. }
  427. })
  428. }).catch(() => {
  429. this.$message({ type: 'info', message: '已取消删除' })
  430. })
  431. },
  432. handleSelectionChange(val) {
  433. console.log('勾选数据', val)
  434. this.selectList = val
  435. },
  436. handleDelete() {
  437. console.log('点击了删除')
  438. if (this.selectList.length == 0) {
  439. this.$message({ type: 'error', message: '请选择栏舍剩料记录', duration: 2000 })
  440. } else {
  441. MessageBox.confirm('是否确认删除此信息?', {
  442. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  443. }).then(() => {
  444. console.log(this.selectList)
  445. this.requestParam.common = { 'returnmap': '0' }
  446. this.requestParam.data = []
  447. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  448. this.requestParam.data[0].children = []
  449. this.requestParam.data[0].children[0] = { 'name': 'deleteBarfeedremain', 'type': 'e', 'parammaps': {
  450. id: '@insertSpotList.id',
  451. pastureid: '@insertSpotList.pastureid'
  452. }}
  453. ExecDataByConfig(this.requestParam).then(response => {
  454. console.log('删除保存发送参数', this.requestParam)
  455. if (response.msg === 'fail') {
  456. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  457. } else {
  458. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  459. this.getList()
  460. }
  461. })
  462. })
  463. }
  464. },
  465. // 复制
  466. handleCopy() {
  467. console.log('点击了复制')
  468. if (this.selectList.length == 0) {
  469. this.$message({ type: 'error', message: '请选择栏舍剩料记录', duration: 2000 })
  470. } else if (this.selectList.length == 1) {
  471. MessageBox.confirm('是否确认复制此信息?', {
  472. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  473. }).then(() => {
  474. this.requestParam.name = 'copybarfeedremain'
  475. this.requestParam.parammaps = {}
  476. this.requestParam.parammaps.pastureid = this.selectList[0].pastureid
  477. this.requestParam.parammaps.id = this.selectList[0].id
  478. PostDataByName(this.requestParam).then(response => {
  479. if (response.msg === 'fail') {
  480. if (response.data.indexOf('barid')) {
  481. this.$message({ type: 'error', message: '该栏舍今日剩料记录已存在,不可重复生成', duration: 2000 })
  482. } else {
  483. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  484. }
  485. } else {
  486. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  487. this.getList()
  488. }
  489. })
  490. }).catch(() => {
  491. this.$message({ type: 'info', message: '已取消删除' })
  492. })
  493. } else {
  494. this.$message({ type: 'error', message: '请选择一条栏舍剩料记录', duration: 2000 })
  495. }
  496. },
  497. // 导出
  498. handleExport() {
  499. console.log('点击了导出')
  500. },
  501. // 导入
  502. handleImport() {
  503. console.log('点击了导入')
  504. }
  505. }
  506. }
  507. </script>
  508. <style lang="scss" scoped>
  509. .search{padding-top:10px;clear: both;}
  510. .table{margin-top:10px;}
  511. </style>