index-data.vue 13 KB

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