cBom-list.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <el-dialog
  3. title="选择"
  4. :visible.sync="cBomListDialogFlag"
  5. :before-close="handleClose"
  6. :close-on-click-modal="false"
  7. top="5vh"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. width="80%"
  11. >
  12. <el-card shadow="never">
  13. <el-form
  14. size="small"
  15. label-width="60px"
  16. @keyup.enter.native="search"
  17. @submit.native.prevent
  18. >
  19. <el-row :gutter="10">
  20. <el-col :span="6">
  21. <el-form-item label="编码">
  22. <el-input
  23. clearable
  24. size="small"
  25. v-model="where.code"
  26. placeholder="请输入"
  27. />
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="6">
  31. <el-form-item label="名称">
  32. <el-input
  33. clearable
  34. size="small"
  35. v-model="where.name"
  36. placeholder="请输入"
  37. />
  38. </el-form-item>
  39. </el-col>
  40. <el-col :span="6">
  41. <el-form-item label="规格">
  42. <el-input
  43. clearable
  44. size="small"
  45. v-model="where.specification"
  46. placeholder="请输入"
  47. />
  48. </el-form-item>
  49. </el-col>
  50. <el-col :span="6">
  51. <el-form-item>
  52. <el-button
  53. size="small"
  54. type="primary"
  55. icon="el-icon-search"
  56. class="ele-btn-icon"
  57. @click="search"
  58. >
  59. 查询
  60. </el-button>
  61. <el-button
  62. @click="reset"
  63. icon="el-icon-refresh"
  64. class="ele-btn-icon"
  65. size="medium"
  66. >重置
  67. </el-button>
  68. <slot></slot>
  69. </el-form-item>
  70. </el-col>
  71. </el-row>
  72. </el-form>
  73. <ele-pro-table
  74. ref="table"
  75. :need-page="false"
  76. :columns="cBomColumns"
  77. :datasource="datasource"
  78. v-loading="loading"
  79. row-key="id"
  80. height="calc(100vh - 480px)"
  81. class="dict-table"
  82. :selection.sync="selection"
  83. >
  84. <!-- 表头工具栏 -->
  85. <template v-slot:action="{ row }">
  86. <el-radio class="radio" v-model="radio" :label="row.code">
  87. <i></i>
  88. </el-radio>
  89. </template>
  90. </ele-pro-table>
  91. </el-card>
  92. <div slot="footer">
  93. <el-button type="primary" size="small" @click="selected">选择</el-button>
  94. <el-button size="small" @click="handleClose">关闭</el-button>
  95. </div>
  96. </el-dialog>
  97. </template>
  98. <script>
  99. import { getCBomAPI } from '@/api/main';
  100. import {getInventoryTotalAPI} from "@/api/wms";
  101. export default {
  102. props: {
  103. /*是否需要获取仓库产品数量*/
  104. isGetInventoryTotal: {
  105. type: Boolean,
  106. default: false
  107. },
  108. /*已选择的产品*/
  109. currentRow: {
  110. type: Object,
  111. default: () => {}
  112. },
  113. cBomListDialogFlag: {
  114. type: Boolean,
  115. default: false
  116. }
  117. },
  118. data() {
  119. return {
  120. selection: [],
  121. datasource: [],
  122. oldDatasource: [],
  123. loading: false,
  124. where: {
  125. name: '',
  126. code: ''
  127. }
  128. };
  129. },
  130. watch: {},
  131. computed: {
  132. cBomColumns() {
  133. return [
  134. {
  135. label: '选择',
  136. width: 45,
  137. type: 'selection',
  138. columnKey: 'selection',
  139. align: 'center'
  140. },
  141. {
  142. columnKey: 'index',
  143. type: 'index',
  144. width: 50,
  145. align: 'center',
  146. showOverflowTooltip: true,
  147. label: '序号'
  148. },
  149. {
  150. prop: 'category.categoryLevelPath',
  151. label: '分类',
  152. align: 'center',
  153. showOverflowTooltip: true
  154. },
  155. {
  156. prop: 'code',
  157. label: '编码',
  158. align: 'center',
  159. showOverflowTooltip: true,
  160. minWidth: 110
  161. },
  162. {
  163. prop: 'name',
  164. label: '名称',
  165. align: 'center',
  166. showOverflowTooltip: true,
  167. minWidth: 110
  168. },
  169. {
  170. prop: 'category.brandNum',
  171. align: 'center',
  172. label: '牌号',
  173. showOverflowTooltip: true
  174. },
  175. {
  176. prop: 'specification',
  177. label: '规格',
  178. align: 'center',
  179. showOverflowTooltip: true
  180. },
  181. {
  182. prop: 'modelType',
  183. label: '型号',
  184. align: 'center',
  185. showOverflowTooltip: true
  186. },
  187. {
  188. prop: 'dosage',
  189. label: '用量',
  190. align: 'center',
  191. showOverflowTooltip: true
  192. },
  193. {
  194. prop: 'unit',
  195. label: '单位',
  196. align: 'center',
  197. showOverflowTooltip: true
  198. },
  199. {
  200. prop: 'versions',
  201. label: '版本',
  202. align: 'center',
  203. showOverflowTooltip: true
  204. }
  205. ];
  206. }
  207. },
  208. methods: {
  209. open(item) {
  210. this.getCBomDatasource();
  211. },
  212. /* 表格数据源 */
  213. async getCBomDatasource() {
  214. this.loading = true;
  215. this.datasource = await getCBomAPI({
  216. categoryId: this.currentRow?.id,
  217. bomType: 1,
  218. produceType: 2
  219. });
  220. this.oldDatasource = this.datasource;
  221. this.loading = false;
  222. /*
  223. * this.$util.toTreeData({
  224. data: list,
  225. idField: 'id',
  226. parentIdField: 'parentId'
  227. });*/
  228. },
  229. search() {
  230. //tableData.filter(data => !search || data.name.toLowerCase().includes(search.toLowerCase()))
  231. this.loading = true;
  232. this.loading = false;
  233. this.datasource = this.oldDatasource.filter((data) => {
  234. return (
  235. data.name.toLowerCase().includes(this.where.name.toLowerCase()) &&
  236. data.code.toLowerCase().includes(this.where.code.toLowerCase()) &&
  237. data.specification
  238. .toLowerCase()
  239. .includes(this.where.specification.toLowerCase())
  240. );
  241. });
  242. },
  243. /* 刷新表格 */
  244. reset() {
  245. this.where = {
  246. name: '',
  247. code: '',
  248. specification: ''
  249. };
  250. this.datasource = this.oldDatasource;
  251. },
  252. handleClose() {
  253. this.$emit('update:cBomListDialogFlag', false);
  254. },
  255. async selected() {
  256. if (!this.selection.length) {
  257. return this.$message.warning('请至少选择一条数据');
  258. }
  259. let codeList = [];
  260. let list = this.selection;
  261. //获取仓库库存
  262. if (this.isGetInventoryTotal) {
  263. codeList = list.map((item) => item.code);
  264. let inventoryTotalList = await getInventoryTotalAPI(codeList);
  265. list.forEach((item) => {
  266. let find =
  267. inventoryTotalList.find((key) => key.code == item.code) || {};
  268. item.availableCountBase = find.availableCountBase;
  269. });
  270. }
  271. this.$emit('changeParent', list);
  272. this.handleClose();
  273. }
  274. }
  275. };
  276. </script>
  277. <style lang="scss" scoped>
  278. .tree_col {
  279. border: 1px solid #eee;
  280. padding: 10px 0;
  281. box-sizing: border-box;
  282. height: 500px;
  283. overflow: auto;
  284. }
  285. .table_col {
  286. padding-left: 10px;
  287. ::v-deep .el-table th.el-table__cell {
  288. background: #f2f2f2;
  289. }
  290. }
  291. .pagination {
  292. text-align: right;
  293. padding: 10px 0;
  294. }
  295. .btns {
  296. text-align: center;
  297. padding: 10px 0;
  298. }
  299. .topsearch {
  300. margin-bottom: 15px;
  301. }
  302. </style>