index-data.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. <template>
  2. <div>
  3. <!-- 数据表格 -->
  4. <ele-pro-table
  5. ref="table"
  6. :columns="newColumns"
  7. :datasource="datasource"
  8. :need-page="true"
  9. :selection.sync="selection"
  10. :current.sync="rowCurrent"
  11. highlight-current-row
  12. height="calc(100vh - 412px)"
  13. full-height="calc(100vh - 116px)"
  14. tool-class="ele-toolbar-form"
  15. cache-key="systemDictDataTable"
  16. >
  17. <!-- 表头工具栏 -->
  18. <template v-slot:toolbar>
  19. <el-button
  20. size="small"
  21. type="primary"
  22. icon="el-icon-plus"
  23. class="ele-btn-icon"
  24. @click="openEdit({}, 2)"
  25. >
  26. 新建
  27. </el-button>
  28. <div class="upload" v-if="rootTreeId == 6">
  29. <el-upload
  30. v-if="!isLoading"
  31. :show-file-list="false"
  32. class="upload-demo"
  33. action=""
  34. :before-upload="beforeUpload"
  35. :on-success="successUpload"
  36. :on-error="errorUpload"
  37. >
  38. <slot>
  39. <el-button
  40. type="primary"
  41. size="small"
  42. plain
  43. icon="el-icon-upload2"
  44. >导入</el-button
  45. >
  46. </slot>
  47. </el-upload>
  48. <el-button
  49. v-else
  50. type="primary"
  51. size="small"
  52. icon="el-icon-upload2"
  53. plain
  54. :loading="isLoading"
  55. >导入</el-button
  56. >
  57. </div>
  58. <el-button
  59. v-else
  60. type="primary"
  61. size="small"
  62. icon="el-icon-upload2"
  63. plain
  64. @click="uploadFile"
  65. >导入</el-button
  66. >
  67. <!-- <el-button
  68. v-if="rootTreeId == 9"
  69. size="small"
  70. type="primary"
  71. @click="handleLink('4')"
  72. >关联设备</el-button
  73. >
  74. <el-button
  75. v-if="rootTreeId == 9"
  76. size="small"
  77. type="primary"
  78. @click="handleLink('5')"
  79. >关联模具</el-button
  80. >
  81. <el-button
  82. v-if="rootTreeId == 9"
  83. size="small"
  84. type="primary"
  85. @click="handleLink('8')"
  86. >关联舟皿</el-button
  87. >
  88. <el-button
  89. v-if="rootTreeId == 4"
  90. size="small"
  91. type="primary"
  92. @click="handleLink('5')"
  93. >关联模具</el-button
  94. >
  95. <el-button
  96. v-if="rootTreeId == 4"
  97. size="small"
  98. type="primary"
  99. @click="handleLink('6')"
  100. >关联备品备件</el-button
  101. >-->
  102. </template>
  103. <template v-slot:action="{ row }">
  104. <el-link type="primary" :underline="false" @click="openEdit(row, 1)">
  105. 复制
  106. </el-link>
  107. <el-link type="primary" :underline="false" @click="openEdit(row, 0)">
  108. 修改
  109. </el-link>
  110. <el-popconfirm
  111. class="ele-action"
  112. title="确定要删除此物料吗?"
  113. @confirm="remove(row)"
  114. >
  115. <template v-slot:reference>
  116. <el-link type="danger" :underline="false"> 删除 </el-link>
  117. </template>
  118. </el-popconfirm>
  119. <el-link
  120. type="primary"
  121. v-if="row.isProduct == 1"
  122. :underline="false"
  123. @click="openParam(row)"
  124. >
  125. 工艺参数
  126. </el-link>
  127. <el-link type="primary" :underline="false" @click="toBomManager(row)">
  128. 结构BOM
  129. </el-link>
  130. <!-- <el-link
  131. type="primary"
  132. v-if="row.isProduct == 1"
  133. :underline="false"
  134. @click="openMaterial(row)"
  135. >
  136. 物料BOM
  137. </el-link> -->
  138. <!-- <el-link
  139. type="primary"
  140. v-if="row.isProduct == 1"
  141. :underline="false"
  142. @click="openMould(row)"
  143. >
  144. 模具
  145. </el-link> -->
  146. <el-link
  147. type="primary"
  148. v-if="row.categoryLevelPathIdParent == 7"
  149. :underline="false"
  150. @click="handAllocation(row)"
  151. >
  152. 货位
  153. </el-link>
  154. <el-link
  155. type="primary"
  156. v-if="row.categoryLevelPathIdParent == 11"
  157. :underline="false"
  158. @click="handleAridRegion(row)"
  159. >
  160. 干燥区
  161. </el-link>
  162. </template>
  163. </ele-pro-table>
  164. <!-- 编辑弹窗 -->
  165. <!-- <dict-edit :visible.sync="showEdit" :id="id" @done="reload" /> -->
  166. <!-- 选择物料 -->
  167. <MaterialModal
  168. :visible.sync="materialEdit"
  169. :data="current"
  170. ref="materialRefs"
  171. ></MaterialModal>
  172. <!-- 工艺参数 -->
  173. <ParamEdit
  174. :visible.sync="paramEditShow"
  175. :paramData="current"
  176. ref="paramRefs"
  177. ></ParamEdit>
  178. <!-- 模具 -->
  179. <mouldDialog
  180. :visible.sync="mouldShow"
  181. :data="current"
  182. ref="mouldRefs"
  183. ></mouldDialog>
  184. <linkMaterialDialog ref="linkMaterialDialogRef" @success="success" />
  185. <!-- 货位 -->
  186. <goodsAllocation ref="allocationRef"></goodsAllocation>
  187. <!-- 干燥区 -->
  188. <aridRegion ref="aridRegionRef"></aridRegion>
  189. <!-- 导入错误弹框 -->
  190. <el-dialog
  191. title="导入失败"
  192. :visible.sync="exportErrorDioalogVisible"
  193. width="60%"
  194. >
  195. <el-table :data="errorData" style="width: 100%">
  196. <el-table-column label="名称" prop="name"> </el-table-column>
  197. <el-table-column label="型号" prop="modeType"> </el-table-column>
  198. <el-table-column label="编号" prop="codeNo"> </el-table-column>
  199. <el-table-column label="物料组" prop="code"> </el-table-column>
  200. <el-table-column label="失败原因" prop="remark"> </el-table-column>
  201. </el-table>
  202. <span slot="footer" class="dialog-footer">
  203. <el-button @click="exportErrorDioalogVisible = false">取 消</el-button>
  204. <el-button type="primary" @click="exportErrorDioalogVisible = false"
  205. >确 定</el-button
  206. >
  207. </span>
  208. </el-dialog>
  209. <importDialog
  210. :defModule="moudleName"
  211. ref="importDialogRef"
  212. @success="reload"
  213. />
  214. <BomDetailsPop ref="bomDrawer"></BomDetailsPop>
  215. </div>
  216. </template>
  217. <script>
  218. import {
  219. getMaterialList,
  220. removeMaterial,
  221. importCategorySparePart
  222. } from '@/api/material/list.js';
  223. import MaterialModal from './MaterialModal.vue';
  224. import ParamEdit from '@/views/technology/productParam/components/user-edit.vue';
  225. import mouldDialog from './mouldDialog';
  226. import linkMaterialDialog from './link-material-dialog.vue';
  227. import goodsAllocation from './goodsAllocation.vue';
  228. import BomDetailsPop from '../../BOMmanage/detailsPop.vue';
  229. import aridRegion from './aridRegion';
  230. import importDialog from '@/components/upload/import-dialog.vue';
  231. import { fieldModel } from '@/api/codeManagement';
  232. export default {
  233. components: {
  234. importDialog,
  235. MaterialModal,
  236. ParamEdit,
  237. mouldDialog,
  238. linkMaterialDialog,
  239. goodsAllocation,
  240. aridRegion,
  241. BomDetailsPop
  242. },
  243. props: {
  244. // 物料组id
  245. currentId: [Number, String],
  246. data: [Array, Object],
  247. rootId: [Number, String],
  248. rootTreeId: [Number, String],
  249. oneProduct: Boolean
  250. },
  251. data() {
  252. return {
  253. moudleName: 'mainCategory',
  254. errorData: [],
  255. exportErrorDioalogVisible: false,
  256. bomShow: false,
  257. // 表格列配置
  258. columns: [
  259. {
  260. columnKey: 'index',
  261. type: 'index',
  262. width: 50,
  263. align: 'center',
  264. showOverflowTooltip: true,
  265. label: '序号'
  266. },
  267. {
  268. prop: 'code',
  269. label: '编码',
  270. align: 'center',
  271. showOverflowTooltip: true,
  272. minWidth: 110
  273. },
  274. {
  275. prop: 'name',
  276. label: '名称',
  277. align: 'center',
  278. showOverflowTooltip: true,
  279. minWidth: 110
  280. },
  281. {
  282. prop: 'brandNum',
  283. align: 'center',
  284. label: '牌号',
  285. showOverflowTooltip: true
  286. },
  287. {
  288. prop: 'modelType',
  289. label: '型号',
  290. align: 'center',
  291. showOverflowTooltip: true
  292. },
  293. {
  294. prop: 'specification',
  295. label: '规格',
  296. align: 'center',
  297. showOverflowTooltip: true
  298. },
  299. {
  300. prop: 'level',
  301. label: '级别',
  302. align: 'center',
  303. showOverflowTooltip: true
  304. },
  305. {
  306. prop: 'measuringUnit',
  307. label: '计量单位',
  308. showOverflowTooltip: true,
  309. minWidth: 90
  310. },
  311. {
  312. prop: 'weightUnit',
  313. label: '重量单位',
  314. showOverflowTooltip: true,
  315. minWidth: 90
  316. },
  317. {
  318. prop: 'roughWeight',
  319. label: '毛重',
  320. showOverflowTooltip: true,
  321. minWidth: 90
  322. },
  323. {
  324. prop: 'netWeight',
  325. label: '净重',
  326. showOverflowTooltip: true,
  327. minWidth: 90
  328. },
  329. {
  330. prop: 'packingUnit',
  331. align: 'center',
  332. label: '包装单位',
  333. showOverflowTooltip: true
  334. },
  335. {
  336. prop: 'categoryLevelPath',
  337. label: '分类',
  338. align: 'center',
  339. showOverflowTooltip: true
  340. }
  341. ],
  342. newColumns: [],
  343. // 表格选中数据
  344. selection: [],
  345. // 是否显示编辑弹窗
  346. showEdit: false,
  347. id: null,
  348. materialEdit: false,
  349. paramEditShow: false,
  350. mouldShow: false,
  351. current: null,
  352. rowCurrent: null,
  353. isLoading: false
  354. };
  355. },
  356. created() {
  357. this.getFieldModel();
  358. },
  359. methods: {
  360. toBomManager(row) {
  361. let rowData = {
  362. categoryId: row.id,
  363. categoryName: row.name,
  364. code: row.code,
  365. rootPathIdParent: row.categoryLevelPathIdParent,
  366. isProduct: row.isProduct == 1
  367. };
  368. this.$refs.bomDrawer.open(rowData);
  369. },
  370. successUpload(response) {
  371. this.isLoading = false;
  372. },
  373. errorUpload(response) {
  374. this.isLoading = false;
  375. },
  376. // 上传备品备件
  377. beforeUpload(file) {
  378. if (file.size / 1024 / 1024 > this.size) {
  379. this.$message.error(`大小不能超过 ${this.size}MB`);
  380. return false;
  381. }
  382. if (this.limit > 0 && this.fileList.length === this.limit) {
  383. this.$message.error(`最多上传 ${this.limit}个文件`);
  384. return false;
  385. }
  386. let formData = new FormData();
  387. formData.append('file', file);
  388. this.isLoading = true;
  389. return importCategorySparePart(formData).then((res) => {
  390. if (res.data.length > 0) {
  391. this.exportErrorDioalogVisible = true;
  392. this.errorData = res.data;
  393. } else {
  394. this.$message.success('导入成功!');
  395. }
  396. this.isLoading = false;
  397. return false;
  398. });
  399. },
  400. /* 表格数据源 */
  401. datasource({ page, limit, where, order }) {
  402. return getMaterialList({
  403. pageNum: page,
  404. size: limit,
  405. ...where,
  406. categoryLevelId: this.currentId
  407. });
  408. },
  409. /* 刷新表格 */
  410. reload(where) {
  411. this.$refs.table.reload({
  412. page: 1,
  413. where: where,
  414. categoryLevelId: this.currentId
  415. });
  416. },
  417. getFieldModel() {
  418. fieldModel({ relevance: 't_main_category' }).then((res) => {
  419. const privateColumn = [
  420. {
  421. columnKey: 'action',
  422. label: '操作',
  423. width: 220,
  424. align: 'center',
  425. resizable: false,
  426. slot: 'action',
  427. fixed: 'right'
  428. }
  429. ];
  430. let newRes = res.map((m) => {
  431. return {
  432. prop: 'extField.' + m.prop,
  433. label: m.label,
  434. align: 'center',
  435. showOverflowTooltip: true
  436. };
  437. });
  438. this.newColumns = [...this.columns, ...newRes, ...privateColumn];
  439. this.$forceUpdate();
  440. });
  441. },
  442. /* 显示编辑 */
  443. openEdit(row, status) {
  444. this.$router.push({
  445. path: '/material/product/detail',
  446. query: {
  447. id: row.id ? row.id : null,
  448. status: status,
  449. rootId: this.rootId,
  450. oneProduct: this.oneProduct,
  451. t: new Date().getTime()
  452. }
  453. });
  454. },
  455. /* 删除 */
  456. remove(row) {
  457. const loading = this.$loading({ lock: true });
  458. removeMaterial(row.id)
  459. .then((msg) => {
  460. loading.close();
  461. this.$message.success('删除' + msg);
  462. this.reload();
  463. })
  464. .catch((e) => {
  465. loading.close();
  466. // this.$message.error(e.message);
  467. });
  468. },
  469. openMaterial(row) {
  470. this.current = row;
  471. this.materialEdit = true;
  472. this.$refs.materialRefs.$refs.form &&
  473. this.$refs.materialRefs.$refs.form.clearValidate();
  474. },
  475. openParam(row) {
  476. this.paramEditShow = true;
  477. this.current = row;
  478. this.$refs.paramRefs.$refs.form &&
  479. this.$refs.paramRefs.$refs.form.clearValidate();
  480. },
  481. openMould(row) {
  482. this.current = row;
  483. this.mouldShow = true;
  484. this.$refs.mouldRefs.$refs.form &&
  485. this.$refs.mouldRefs.$refs.form.clearValidate();
  486. },
  487. handleLink(type) {
  488. if (!this.rowCurrent) {
  489. return this.$message.error(
  490. this.rootTreeId == 9
  491. ? '请选择产品!'
  492. : this.rootTreeId == 4
  493. ? '请选择设备!'
  494. : ''
  495. );
  496. }
  497. this.$refs.linkMaterialDialogRef.open(type, this.rowCurrent);
  498. },
  499. success() {
  500. this.reload();
  501. },
  502. handAllocation(row) {
  503. this.$refs.allocationRef.open(row);
  504. },
  505. handleAridRegion(row) {
  506. this.$refs.aridRegionRef.open(row);
  507. },
  508. uploadFile() {
  509. this.$refs.importDialogRef.open();
  510. }
  511. },
  512. watch: {
  513. // 监听物料组id变化
  514. currentId() {
  515. this.reload();
  516. }
  517. }
  518. };
  519. </script>
  520. <style lang="scss" scoped>
  521. .upload {
  522. display: inline-block;
  523. width: 100px;
  524. margin-left: 10px;
  525. }
  526. </style>