warehouse_site.vue 9.8 KB

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