warehouse_site.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :optionsEvensGroup="optionsEvensGroup"
  6. :exportList="exportList"
  7. :operation="operation()"
  8. :tableAttributes="tableAttributes"
  9. :tableEvents="tableEvents"
  10. :columnParsing="columnParsing"
  11. >
  12. <!-- 弹窗 -->
  13. <el-dialog
  14. title="仓库仓位对应关系"
  15. :visible.sync="showDialogForm"
  16. width="30%"
  17. :show-close="false"
  18. :close-on-click-modal="false"
  19. >
  20. <el-form ref="diaLogForm" :model="diaLogForm" label-width="70px" size="small" label-position="left">
  21. <el-form-item label="仓库名称" prop="name">
  22. <el-input v-model="diaLogForm.name"></el-input>
  23. </el-form-item>
  24. <el-form-item label="仓位名称" prop="stockIds">
  25. <el-select v-model="diaLogForm.stockIds" multiple filterable placeholder="请选择">
  26. <el-option v-for="item in cList" :key="item.id" :label="item.name" :value="item.id"> </el-option>
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="库存警戒线" prop="stockCordon">
  30. <el-input v-model="diaLogForm.stockCordon"></el-input>
  31. </el-form-item>
  32. <!-- <el-form-item label="库存状态">
  33. <el-radio v-model="diaLogForm.status" label="1">充足</el-radio>
  34. <el-radio v-model="diaLogForm.status" label="2">补充足</el-radio>
  35. </el-form-item> -->
  36. <el-form-item label="备注" prop="remark">
  37. <el-input type="textarea" v-model="diaLogForm.remark"></el-input>
  38. </el-form-item>
  39. <el-form-item label="虚拟仓" prop="type">
  40. <el-radio v-model="diaLogForm.type" label="2">是</el-radio>
  41. <el-radio v-model="diaLogForm.type" label="1">否</el-radio>
  42. </el-form-item>
  43. </el-form>
  44. <div slot="footer" class="dialog-footer">
  45. <el-button @click="onClose">取 消</el-button>
  46. <el-button type="primary" @click="hanleInfo">确 定</el-button>
  47. </div>
  48. </el-dialog>
  49. </template-page>
  50. </template>
  51. <script>
  52. import TemplatePage from '@/components/template/template-page-1.vue'
  53. import import_mixin from '@/components/template/import_mixin.js'
  54. import add_callback_mixin from '@/components/template/add_callback_mixin.js'
  55. import Popu from '@/components/template/popu.vue'
  56. import {
  57. addStock,
  58. deleteStock,
  59. getList,
  60. getListStockV2,
  61. updateStock,
  62. exportListStockV2,
  63. getStockDetailStock
  64. } from '@/api/basic_data/warehouse'
  65. import { nextTick } from 'process'
  66. export default {
  67. components: { TemplatePage, Popu },
  68. mixins: [import_mixin, add_callback_mixin],
  69. data() {
  70. return {
  71. visible: false,
  72. // 事件组合
  73. optionsEvensGroup: [
  74. [
  75. [
  76. {
  77. name: '新增',
  78. click: this.addOn(() => {
  79. this.newData()
  80. }),
  81. isRole: this.$checkBtnRole('add', this.$route.meta.roles)
  82. }
  83. ]
  84. ],
  85. [
  86. [
  87. {
  88. name: '批量删除',
  89. click: async () => {
  90. if (this.recordSelected.length === 0) {
  91. this.$message.error('请选择需要删除的数据')
  92. return
  93. }
  94. let ids = this.recordSelected.map(v => {
  95. return v.id
  96. })
  97. let params = ids
  98. await deleteStock({ id: params.join(',') })
  99. this.$refs.pageRef.refreshList()
  100. this.$message.success('批量删除成功')
  101. },
  102. isRole: this.$checkBtnRole('del', this.$route.meta.roles)
  103. }
  104. ]
  105. ]
  106. ],
  107. // 表格属性
  108. tableAttributes: {
  109. // 启用勾选列
  110. selectColumn: true
  111. }, // 关闭新增弹窗
  112. // 表格事件
  113. tableEvents: {
  114. 'selection-change': this.selectionChange
  115. },
  116. recordSelected: [],
  117. currentPage: 1, // 当前页码
  118. pageSize: 10, // 每页数量
  119. listTotal: 0, // 列表总数
  120. options: [
  121. {
  122. value: '选项1',
  123. label: '1'
  124. },
  125. {
  126. value: '选项2',
  127. label: '2'
  128. },
  129. {
  130. value: '选项3',
  131. label: '3'
  132. },
  133. {
  134. value: '选项4',
  135. label: '4'
  136. },
  137. {
  138. value: '选项5',
  139. label: '5'
  140. }
  141. ],
  142. diaLogForm: {
  143. id: null,
  144. type: '1',
  145. name: '',
  146. remark: '',
  147. status: 1,
  148. stockCordon: 0,
  149. stockIds: [],
  150. updateBy: '',
  151. updateTime: ''
  152. },
  153. showDialogForm: false,
  154. screenForm: {
  155. name: '',
  156. stockName: ''
  157. },
  158. screenForm2: {
  159. // 筛选表单数据
  160. name: '' // 名称
  161. },
  162. type: null,
  163. cList: {}
  164. }
  165. },
  166. methods: {
  167. // 列表请求函数
  168. getList(...p) {
  169. this.recordSelected = []
  170. return getListStockV2(...p)
  171. },
  172. // 列表导出函数
  173. exportList: exportListStockV2,
  174. // 表格列解析渲染数据更改
  175. columnParsing(item, defaultData) {
  176. return defaultData
  177. },
  178. // 监听勾选变化
  179. selectionChange(data) {
  180. this.recordSelected = data
  181. },
  182. operation() {
  183. return (h, { row, index, column }) => {
  184. return (
  185. <div class="operation-btns">
  186. {this.$checkBtnRole('edit', this.$route.meta.roles) ? (
  187. <el-button
  188. size="mini"
  189. type="text"
  190. onClick={() => {
  191. this.editFn(row.id)
  192. }}
  193. >
  194. 编辑
  195. </el-button>
  196. ) : null}
  197. {this.$checkBtnRole('del', this.$route.meta.roles) ? (
  198. <el-popconfirm
  199. confirm-button-text="好的"
  200. cancel-button-text="不用了"
  201. icon="el-icon-info"
  202. icon-color="red"
  203. title="内容确定删除吗?"
  204. onOnConfirm={() => {
  205. this.hanleDelete(row.id)
  206. }}
  207. >
  208. <el-button size="mini" slot="reference" type="text" class="textColor el-popover-left">
  209. 删除
  210. </el-button>
  211. </el-popconfirm>
  212. ) : null}
  213. </div>
  214. )
  215. }
  216. },
  217. onClose() {
  218. this.diaLogForm = {
  219. id: null,
  220. type: '1',
  221. name: '',
  222. remark: '',
  223. status: 1,
  224. stockCordon: 0,
  225. stockIds: [],
  226. updateBy: '',
  227. updateTime: ''
  228. }
  229. this.addOff(() => {
  230. this.showDialogForm = false
  231. })()
  232. },
  233. newData() {
  234. this.showDialogForm = true
  235. this.type = 1
  236. const params = {
  237. pageNum: 1,
  238. pageSize: -1,
  239. name: ''
  240. }
  241. getList(params).then(res => {
  242. this.cList = res.data.records
  243. this.listTotal = res.data.total
  244. })
  245. },
  246. //显示编辑,编辑数据初始化
  247. editFn(id) {
  248. let row
  249. getStockDetailStock({ id }).then(res => {
  250. row = res.data
  251. this.type = 2
  252. const arr = []
  253. if (row.kingDeeStocks && row.kingDeeStocks.length > 0) {
  254. row.kingDeeStocks.forEach(el => {
  255. arr.push(el.id)
  256. })
  257. }
  258. this.newData()
  259. this.diaLogForm = {
  260. id,
  261. name: row.name,
  262. remark: row.remark,
  263. status: row.status,
  264. stockCordon: row.stockCordon,
  265. type: row.type + '',
  266. stockIds: row.stockIds === undefined ? arr : row.stockIds
  267. }
  268. this.showDialogForm = true
  269. })
  270. },
  271. hanleInfo() {
  272. console.log(this.type)
  273. if (this.type == 1) {
  274. addStock(this.diaLogForm).then(res => {
  275. this.$successMsg('保存成功')
  276. this.showDialogForm = false
  277. this.$refs.pageRef.refreshList()
  278. })
  279. } else if (this.type == 2) {
  280. const params = {
  281. ...this.diaLogForm
  282. }
  283. updateStock(params).then(res => {
  284. this.$successMsg('编辑成功')
  285. this.showDialogForm = false
  286. this.$refs.pageRef.refreshList()
  287. })
  288. }
  289. this.diaLogForm = {
  290. name: '',
  291. remark: '',
  292. type: '1',
  293. status: 0,
  294. stockCordon: 0,
  295. stockIds: [],
  296. updateBy: '',
  297. updateTime: ''
  298. }
  299. },
  300. // 删除数据
  301. hanleDelete(id) {
  302. deleteStock({ id: [id].join('') }).then(res => {
  303. this.$successMsg('删除成功')
  304. this.$refs.pageRef.refreshList()
  305. })
  306. }
  307. }
  308. }
  309. </script>
  310. <style lang="scss" scoped>
  311. ::v-deep .el-date-editor {
  312. width: 100%;
  313. }
  314. ::v-deep .el-select {
  315. width: 100%;
  316. }
  317. ::v-deep .el-col-9 .el-button {
  318. padding: 5px;
  319. }
  320. ::v-deep .el-dialog__header {
  321. background-color: #dddddd;
  322. }
  323. .base {
  324. padding: 20px 20px 0;
  325. }
  326. .table {
  327. margin-top: 12px;
  328. }
  329. .right {
  330. float: right;
  331. }
  332. </style>