8e90207a45f72bb54b612513e4c7fe31d89343de.svn-base 21 KB

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