7f94d365ccd44730acc2d1514b59670713e50bd5.svn-base 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button class="success" @click="handleCreate">新增盘点单</el-button>
  5. <el-button class="success" @click="handleInventoryList">下载盘点单</el-button>
  6. </div>
  7. <div class="search">
  8. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
  9. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  10. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  11. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  12. </div>
  13. <div class="table">
  14. <el-table
  15. :key="table.tableKey"
  16. v-loading="table.listLoading"
  17. element-loading-text="给我一点时间"
  18. :data="table.list"
  19. border
  20. fit
  21. highlight-current-row
  22. style="width: 100%;"
  23. :row-style="rowStyle"
  24. :cell-style="cellStyle"
  25. class="elTable table-fixed"
  26. >
  27. <el-table-column label="序号" align="center" type="index" width="50px">
  28. <template slot-scope="scope">
  29. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="盘点日期" min-width="130px" align="center">
  33. <template slot-scope="scope">
  34. <span>{{ scope.row.inventorydate }}</span>
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="盘点人" min-width="130px" align="center">
  38. <template slot-scope="scope">
  39. <span>{{ scope.row.createuser }}</span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="盘盈库存(kg)" min-width="110px" align="center">
  43. <template slot-scope="scope">
  44. <span>{{ scope.row.moreWeight }}</span>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="盘亏库存(kg)" min-width="110px" align="center">
  48. <template slot-scope="scope">
  49. <span>{{ scope.row.lessWeight }}</span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="盈亏净值(kg)" min-width="110px" align="center">
  53. <template slot-scope="scope">
  54. <span>{{ scope.row.differWeight }}</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="备注" min-width="110px" align="center">
  58. <template slot-scope="scope">
  59. <span>{{ scope.row.remark }}</span>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="操作" align="center" width="320" class-name="small-padding fixed-width" fixed="right">
  63. <template slot-scope="scope">
  64. <el-button class="miniPrimary" :disabled="isokDisable" @click="handleSee(scope.row)">查看</el-button>
  65. <el-button v-if="scope.$index + (table.pageNum-1) * table.pageSize + 1 == 1" class="miniDanger" @click="handleRowDelete(scope.row)">删除</el-button>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  70. </div>
  71. <!-- 新增盘点单 -->
  72. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  73. <div class="app-add">
  74. <el-form ref="createTemp" :rules="create.rules" :model="create.createTemp" label-position="right" label-width="160px" style="width: 90%;margin:0 auto">
  75. <el-row>
  76. <el-col :span="8">
  77. <el-form-item label="盘点日期:" prop="inventorydate">
  78. <el-date-picker v-model="create.createTemp.inventorydate" class="filter-item" type="date" placeholder="盘点日期" :disabled="create.dialogStatus==='see'" :picker-options="create.pickerOptions1" :clearable="false" />
  79. </el-form-item>
  80. </el-col>
  81. <el-col :span="8">
  82. <el-form-item label="盘点人:" prop="createuser">
  83. <el-input ref="createuser" v-model="create.createTemp.createuser" class="filter-item" placeholder="盘点人" type="text" disabled />
  84. </el-form-item>
  85. </el-col>
  86. <el-col :span="8">
  87. <el-form-item label="备注:" prop="remark">
  88. <el-input ref="remark" v-model="create.createTemp.remark" class="filter-item" placeholder="备注" type="text" :disabled="create.dialogStatus==='see'" />
  89. </el-form-item>
  90. </el-col>
  91. </el-row>
  92. </el-form>
  93. <el-table
  94. :key="create.tableKey"
  95. v-loading="create.listLoading"
  96. element-loading-text="给我一点时间"
  97. :data="create.list"
  98. border
  99. fit
  100. highlight-current-row
  101. style="width: 100%;margin-bottom: 50px;"
  102. :row-style="rowStyle"
  103. :cell-style="cellStyle"
  104. class="elTable table-fixed"
  105. >
  106. <el-table-column label="饲料名称" min-width="130px" align="center">
  107. <template slot-scope="scope">
  108. <span>{{ scope.row.feedname }}</span>
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="库存重量(kg)" min-width="130px" align="center">
  112. <template slot-scope="scope">
  113. <span>{{ scope.row.stockweight }}</span>
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="实际重量(kg)" min-width="110px" align="center">
  117. <template slot-scope="scope">
  118. <el-input v-if="create.dialogStatus==='create'" ref="input" v-model="scope.row.factweight" style="width:80%;padding:10px 0;" @blur="blurFactweight(scope.row)" />
  119. <span v-else> {{ scope.row.factweight }}</span>
  120. </template>
  121. </el-table-column>
  122. <el-table-column label="差值(kg)" min-width="110px" align="center">
  123. <template slot-scope="scope">
  124. <span>{{ scope.row.differ }}</span>
  125. </template>
  126. </el-table-column>
  127. </el-table>
  128. <div slot="footer" class="dialog-footer">
  129. <el-button class="cancel" @click="create.dialogFormVisible = false; ">关闭</el-button>
  130. <el-button v-if="create.dialogStatus==='create'" class="success" :disabled="isokDisable" @click="createData()">确认</el-button>
  131. </div>
  132. </div>
  133. </el-dialog>
  134. </div>
  135. </template>
  136. <script>
  137. import { GetDataByName, ExecDataByConfig, failproccess, PostDataByName } from '@/api/common'
  138. import Pagination from '@/components/Pagination'
  139. import { parseTime } from '@/utils/index.js'
  140. import { MessageBox } from 'element-ui'
  141. import Cookies from 'js-cookie'
  142. export default {
  143. name: 'InventoryList',
  144. components: { Pagination },
  145. data() {
  146. return {
  147. table: {
  148. getdataListParm: {
  149. name: 'getBigInventoryList',
  150. page: 1,
  151. offset: 1,
  152. pagecount: 10,
  153. returntype: 'Map',
  154. parammaps: {
  155. pastureid: Cookies.get('pastureid'),
  156. startTime: '',
  157. stopTime: '',
  158. inputDatetime: ''
  159. }
  160. },
  161. tableKey: 0,
  162. list: [],
  163. total: 0,
  164. listLoading: true
  165. },
  166. textMap: {
  167. create: '新增',
  168. see: '查看盘点单'
  169. },
  170. create: {
  171. pickerOptions1: {
  172. disabledDate(time) {
  173. return time.getTime() > Date.now()// 当天之前的时间可选
  174. }
  175. },
  176. dialogFormVisible: false,
  177. dialogStatus: '',
  178. createTemp: {
  179. pastureid: Cookies.get('pastureid'),
  180. remark: '',
  181. inventorydate: parseTime(new Date(), '{y}-{m}-{d}'),
  182. createuser: Cookies.get('employename')
  183. },
  184. rules: {},
  185. getdataListParm: {
  186. name: 'getFeedstorageWeightList',
  187. page: 1,
  188. offset: 1,
  189. pagecount: '',
  190. returntype: 'Map',
  191. parammaps: {
  192. pastureid: Cookies.get('pastureid'),
  193. emp: Cookies.get('employename')
  194. }
  195. },
  196. tableKey: 0,
  197. list: [],
  198. total: 0,
  199. listLoading: true
  200. },
  201. see: {
  202. getdataListParm: {
  203. name: 'getInventoryList',
  204. page: 1,
  205. offset: 1,
  206. pagecount: 10,
  207. returntype: 'Map',
  208. parammaps: {}
  209. }
  210. },
  211. requestParam: {},
  212. isokDisable: false,
  213. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  214. cellStyle: { padding: 0 + 'px' }
  215. }
  216. },
  217. created() {
  218. this.getList()
  219. },
  220. methods: {
  221. handleBefore() {
  222. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  223. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  224. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  225. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  226. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  227. this.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  228. this.table.getdataListParm.parammaps.stopTime = parseTime(stop, '{y}-{m}-{d}')
  229. this.$forceUpdate()
  230. }
  231. },
  232. handleNext() {
  233. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  234. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  235. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  236. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  237. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  238. this.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  239. this.table.getdataListParm.parammaps.stopTime = parseTime(stop, '{y}-{m}-{d}')
  240. this.$forceUpdate()
  241. }
  242. },
  243. handleSearch() {
  244. console.log('点击了查询')
  245. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  246. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  247. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  248. } else {
  249. this.table.getdataListParm.parammaps.inputDatetime = ''
  250. this.table.getdataListParm.parammaps.startTime = ''
  251. this.table.getdataListParm.parammaps.stopTime = ''
  252. }
  253. this.table.getdataListParm.offset = 1
  254. this.getList()
  255. },
  256. getList() {
  257. this.table.listLoading = true
  258. GetDataByName(this.table.getdataListParm).then(response => {
  259. console.log('table数据', response.data.list)
  260. if (response.data.list !== null) {
  261. this.table.list = response.data.list
  262. this.table.pageNum = response.data.pageNum
  263. this.table.pageSize = response.data.pageSize
  264. this.table.total = response.data.total
  265. } else {
  266. this.table.list = []
  267. }
  268. setTimeout(() => {
  269. this.table.listLoading = false
  270. }, 100)
  271. })
  272. },
  273. resetCreateTemp() {
  274. this.create.createTemp = { pastureid: Cookies.get('pastureid'), remark: '', inventorydate: parseTime(new Date(), '{y}-{m}-{d}'), createuser: Cookies.get('employename') }
  275. },
  276. handleCreate() {
  277. console.log('点击了新增盘点单')
  278. this.resetCreateTemp()
  279. this.create.dialogStatus = 'create'
  280. this.create.dialogFormVisible = true
  281. this.getCreateList()
  282. },
  283. getCreateList() {
  284. this.create.listLoading = true
  285. GetDataByName(this.create.getdataListParm).then(response => {
  286. console.log('table数据', response.data.list)
  287. if (response.data.list !== null) {
  288. for (let i = 0; i < response.data.list.length; i++) {
  289. this.$set(response.data.list[i], 'factweight', '')
  290. this.$set(response.data.list[i], 'differ', '')
  291. }
  292. this.create.list = response.data.list
  293. this.create.pageNum = response.data.pageNum
  294. this.create.pageSize = response.data.pageSize
  295. this.create.total = response.data.total
  296. } else {
  297. this.create.list = []
  298. }
  299. setTimeout(() => {
  300. this.create.listLoading = false
  301. }, 100)
  302. })
  303. },
  304. // 实际重量
  305. blurFactweight(row) {
  306. if (row.factweight !== '' && row.stockweight !== '') {
  307. row.differ = parseFloat(row.factweight) - parseFloat(row.stockweight)
  308. }
  309. },
  310. createData() {
  311. this.$refs['createTemp'].validate(valid => {
  312. if (valid) {
  313. this.isokDisable = true
  314. setTimeout(() => {
  315. this.isokDisable = false
  316. }, 1000)
  317. var createList = []
  318. for (let i = 0; i < this.create.list.length; i++) {
  319. if (this.create.list[i].factweight !== '') {
  320. createList.push(this.create.list[i])
  321. }
  322. }
  323. for (let i = 0; i < createList.length; i++) {
  324. const keepTwoNum = /^\d+(\.\d{1,2})?$/
  325. // 实际重量
  326. if (!keepTwoNum.test(parseFloat(createList[i].factweight))) {
  327. this.$message({ type: 'error', message: '实际重量请输入自然数并保留两位小数', duration: 2000 })
  328. return false
  329. }
  330. }
  331. this.requestParam.common = { 'returnmap': '0' }
  332. this.requestParam.data = []
  333. this.requestParam.data[0] = { 'name': 'insertBigInventory', 'type': 'e', 'parammaps': {
  334. 'pastureid': this.create.createTemp.pastureid,
  335. 'inventorydate': parseTime(this.create.createTemp.inventorydate, '{y}-{m}-{d}'),
  336. 'createuser': this.create.createTemp.createuser,
  337. 'remark': this.create.createTemp.remark
  338. }}
  339. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': createList }}
  340. this.requestParam.data[1].children = []
  341. this.requestParam.data[1].children[0] = { 'name': 'insertInventory', 'type': 'e', 'parammaps': {
  342. invid: '@insertBigInventory.LastInsertId',
  343. pastureid: '@insertSpotList.pastureid',
  344. feedname: '@insertSpotList.feedname',
  345. feedid: '@insertSpotList.feedid',
  346. stockweight: '@insertSpotList.stockweight',
  347. factweight: '@insertSpotList.factweight'
  348. }}
  349. ExecDataByConfig(this.requestParam).then(response => {
  350. if (response.msg === 'fail') {
  351. const inventorydate = new RegExp("key 'inventorydate'")
  352. if (inventorydate.test(response.data)) {
  353. this.$message({ type: 'error', message: '当前日期已盘点,不可重复录入', duration: 2000 })
  354. } else {
  355. failproccess(response, this.$notify)
  356. }
  357. } else {
  358. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  359. this.create.dialogFormVisible = false
  360. this.getList()
  361. }
  362. })
  363. }
  364. })
  365. },
  366. handleInventoryList() {
  367. console.log('点击了下载盘点单')
  368. },
  369. handleSee(row) {
  370. console.log('点击了查看')
  371. this.create.dialogStatus = 'see'
  372. this.create.dialogFormVisible = true
  373. this.create.createTemp = Object.assign({}, row)
  374. this.see.getdataListParm.parammaps.pastureid = row.pastureid
  375. this.see.getdataListParm.parammaps.id = row.id
  376. this.getSeeList()
  377. },
  378. getSeeList() {
  379. this.create.listLoading = true
  380. GetDataByName(this.see.getdataListParm).then(response => {
  381. console.log('table数据', response.data.list)
  382. if (response.data.list !== null) {
  383. this.create.list = response.data.list
  384. this.create.pageNum = response.data.pageNum
  385. this.create.pageSize = response.data.pageSize
  386. this.create.total = response.data.total
  387. } else {
  388. this.create.list = []
  389. }
  390. setTimeout(() => {
  391. this.create.listLoading = false
  392. }, 100)
  393. })
  394. },
  395. handleRowDelete(row) {
  396. MessageBox.confirm('是否确认删除此信息?', {
  397. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  398. }).then(() => {
  399. this.requestParam.name = 'deleteBigInventory'
  400. this.requestParam.parammaps = {}
  401. this.requestParam.parammaps.pastureid = row.pastureid
  402. this.requestParam.parammaps.id = row.id
  403. PostDataByName(this.requestParam).then(response => {
  404. if (response.msg === 'fail') {
  405. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  406. } else {
  407. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  408. this.getList()
  409. }
  410. })
  411. }).catch(() => {
  412. this.$message({ type: 'info', message: '已取消删除' })
  413. })
  414. }
  415. }
  416. }
  417. </script>
  418. <style lang="scss" scoped>
  419. .search{margin-top:10px;}
  420. .table{margin-top:10px;}
  421. </style>
  422. <style>
  423. .inputDatetime .el-range-separator{ padding: 0; margin: 0 10px; }
  424. </style>