index-data.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415
  1. <template>
  2. <div>
  3. <!-- 数据表格 -->
  4. <ele-pro-table
  5. ref="table"
  6. :columns="columns"
  7. :datasource="datasource"
  8. :need-page="true"
  9. :selection.sync="selection"
  10. :current.sync="rowCurrent"
  11. @sort-change="onSortChange"
  12. highlight-current-row
  13. height="calc(100vh - 500px)"
  14. full-height="calc(100vh - 116px)"
  15. tool-class="ele-toolbar-form"
  16. :page-size="pageSize"
  17. :initLoad="false"
  18. @columns-change="handleColumnChange"
  19. :cache-key="cacheKeyUrl"
  20. v-if="pageShow"
  21. >
  22. <!-- 表头工具栏 -->
  23. <template v-slot:toolbar>
  24. <el-button
  25. size="small"
  26. type="primary"
  27. icon="el-icon-plus"
  28. class="ele-btn-icon"
  29. @click="openEdit({}, 2)"
  30. v-if="$hasPermission('main:category:save')"
  31. >
  32. 新建
  33. </el-button>
  34. <div
  35. class="upload"
  36. v-if="rootTreeId == 6 && $hasPermission('main:category:update')"
  37. >
  38. <el-upload
  39. v-if="!isLoading"
  40. :show-file-list="false"
  41. class="upload-demo"
  42. action=""
  43. :before-upload="beforeUpload"
  44. :on-success="successUpload"
  45. :on-error="errorUpload"
  46. >
  47. <slot>
  48. <el-button
  49. type="primary"
  50. size="small"
  51. plain
  52. icon="el-icon-upload2"
  53. >导入</el-button
  54. >
  55. </slot>
  56. </el-upload>
  57. <el-button
  58. v-else
  59. type="primary"
  60. size="small"
  61. icon="el-icon-upload2"
  62. plain
  63. :loading="isLoading"
  64. >导入</el-button
  65. >
  66. </div>
  67. <el-button
  68. v-if="$hasPermission('main:category:update') && rootTreeId != 6"
  69. type="primary"
  70. size="small"
  71. icon="el-icon-upload2"
  72. plain
  73. @click="uploadFile"
  74. >导入</el-button
  75. >
  76. <el-button
  77. type="warning"
  78. icon="el-icon-download"
  79. size="mini"
  80. @click="handleExport()"
  81. :loading="exportLoading"
  82. >导出</el-button
  83. >
  84. <el-button
  85. v-if="!isBatchPublish"
  86. size="small"
  87. type="primary"
  88. icon="el-icon-s-promotion"
  89. class="ele-btn-icon"
  90. @click="batchPublish"
  91. >
  92. 批量发布
  93. </el-button>
  94. <el-button
  95. size="small"
  96. :disabled="selection.length == 0"
  97. icon="el-icon-thumb"
  98. class="ele-btn-icon"
  99. @click="moveTo()"
  100. v-if="$hasPermission('main:category:update')"
  101. >
  102. 设置采购员
  103. </el-button>
  104. <el-button
  105. size="small"
  106. :disabled="selection.length == 0"
  107. icon="el-icon-thumb"
  108. class="ele-btn-icon"
  109. @click="warehouseOpen"
  110. v-if="$hasPermission('main:category:update')"
  111. >
  112. 设置默认仓库
  113. </el-button>
  114. <!-- <el-button
  115. v-if="rootTreeId == 9"
  116. size="small"
  117. type="primary"
  118. @click="handleLink('4')"
  119. >关联设备</el-button
  120. >
  121. <el-button
  122. v-if="rootTreeId == 9"
  123. size="small"
  124. type="primary"
  125. @click="handleLink('5')"
  126. >关联模具</el-button
  127. >
  128. <el-button
  129. v-if="rootTreeId == 9"
  130. size="small"
  131. type="primary"
  132. @click="handleLink('8')"
  133. >关联舟皿</el-button
  134. >
  135. <el-button
  136. v-if="rootTreeId == 4"
  137. size="small"
  138. type="primary"
  139. @click="handleLink('5')"
  140. >关联模具</el-button
  141. >
  142. <el-button
  143. v-if="rootTreeId == 4"
  144. size="small"
  145. type="primary"
  146. @click="handleLink('6')"
  147. >关联备品备件</el-button
  148. >-->
  149. </template>
  150. <template v-slot:isEnabled="{ row }">
  151. <div>
  152. <el-switch
  153. v-model="row.isEnabled"
  154. active-color="#13ce66"
  155. inactive-color="#ff4949"
  156. :active-value="1"
  157. :inactive-value="0"
  158. :disabled="isApproving(row)"
  159. @change="changeEnable(row)"
  160. >
  161. </el-switch>
  162. </div>
  163. </template>
  164. <template v-slot:code="{ row }">
  165. <el-link type="primary" :underline="false" @click="openEdit(row, 3)">
  166. {{ row.code }}
  167. </el-link>
  168. </template>
  169. <template v-slot:name="{ row }">
  170. <el-link type="primary" :underline="false" @click="openEdit(row, 3)">
  171. {{ row.name }}
  172. </el-link>
  173. </template>
  174. <template v-slot:componentAttribute="{ row }">
  175. <div>
  176. <!-- {{ }} -->
  177. {{ getDictValueFn(row.componentAttribute) }}
  178. </div>
  179. </template>
  180. <template v-slot:approveStatus="{ row }">
  181. <el-tag
  182. v-if="hasApproveStatus(row)"
  183. size="mini"
  184. :type="getApproveStatusTagType(row)"
  185. >
  186. {{ getApproveStatusText(row) }}
  187. </el-tag>
  188. </template>
  189. <template v-slot:action="{ row }">
  190. <!-- <el-link
  191. type="primary"
  192. :underline="false"
  193. @click="openEdit(row, 3)"
  194. v-if="isApproving(row)"
  195. >
  196. 详情
  197. </el-link> -->
  198. <!-- <el-link
  199. type="primary"
  200. :underline="false"
  201. @click="openEdit(row, 1)"
  202. v-if="$hasPermission('main:category:update')"
  203. >
  204. {{ row.isEnabled == 1 ? '停用' : '启用' }}
  205. </el-link> -->
  206. <el-link
  207. type="primary"
  208. :underline="false"
  209. @click="openEdit(row, 1)"
  210. v-if="!isApproving(row) && $hasPermission('main:category:save')"
  211. >
  212. 复制
  213. </el-link>
  214. <!-- <el-link type="primary" :underline="false" @click="openEdit(row, 3)">
  215. 详情
  216. </el-link> -->
  217. <el-link
  218. type="primary"
  219. :underline="false"
  220. @click="openEdit(row, 0)"
  221. v-if="!isApproving(row) && $hasPermission('main:category:update')"
  222. >
  223. 修改
  224. </el-link>
  225. <el-popconfirm
  226. class="ele-action"
  227. title="确定要删除此物料吗?"
  228. @confirm="remove(row)"
  229. v-if="
  230. !isApproving(row) &&
  231. !isApprovePassed(row) &&
  232. $hasPermission('main:category:delete')
  233. "
  234. >
  235. <template v-slot:reference>
  236. <el-link type="danger" :underline="false"> 删除 </el-link>
  237. </template>
  238. </el-popconfirm>
  239. <!-- <el-link
  240. type="primary"
  241. v-if="row.isProduct == 1"
  242. :underline="false"
  243. @click="openParam(row)"
  244. >
  245. 工艺参数
  246. </el-link> -->
  247. <el-link
  248. v-if="!isApproving(row)"
  249. type="primary"
  250. :underline="false"
  251. @click="toBomManager(row)"
  252. >
  253. BOM
  254. </el-link>
  255. <el-link
  256. type="primary"
  257. :underline="false"
  258. @click="publish(row)"
  259. v-if="
  260. !isApproving(row) &&
  261. !isApprovePassed(row) &&
  262. row.isPublished != 1 &&
  263. $hasPermission('main:category:update')
  264. "
  265. >
  266. 发布
  267. </el-link>
  268. <!-- <el-link
  269. type="primary"
  270. v-if="row.isProduct == 1"
  271. :underline="false"
  272. @click="openMaterial(row)"
  273. >
  274. 物料BOM
  275. </el-link> -->
  276. <!-- <el-link
  277. type="primary"
  278. v-if="row.isProduct == 1"
  279. :underline="false"
  280. @click="openMould(row)"
  281. >
  282. 模具
  283. </el-link> -->
  284. <el-link
  285. type="primary"
  286. v-if="!isApproving(row) && row.categoryLevelPathIdParent == 7"
  287. :underline="false"
  288. @click="handAllocation(row)"
  289. >
  290. 货位
  291. </el-link>
  292. <el-link
  293. type="primary"
  294. v-if="!isApproving(row) && row.categoryLevelPathIdParent == 11"
  295. :underline="false"
  296. @click="handleAridRegion(row)"
  297. >
  298. 干燥区
  299. </el-link>
  300. </template>
  301. </ele-pro-table>
  302. <!-- 编辑弹窗 -->
  303. <!-- <dict-edit :visible.sync="showEdit" :id="id" @done="reload" /> -->
  304. <!-- 选择物料 -->
  305. <MaterialModal
  306. :visible.sync="materialEdit"
  307. :data="current"
  308. ref="materialRefs"
  309. ></MaterialModal>
  310. <!-- 工艺参数 -->
  311. <ParamEdit
  312. :visible.sync="paramEditShow"
  313. :paramData="current"
  314. ref="paramRefs"
  315. ></ParamEdit>
  316. <!-- 模具 -->
  317. <mouldDialog
  318. :visible.sync="mouldShow"
  319. :data="current"
  320. ref="mouldRefs"
  321. ></mouldDialog>
  322. <linkMaterialDialog ref="linkMaterialDialogRef" @success="success" />
  323. <!-- 货位 -->
  324. <goodsAllocation ref="allocationRef"></goodsAllocation>
  325. <!-- 干燥区 -->
  326. <aridRegion ref="aridRegionRef"></aridRegion>
  327. <!-- 导入错误弹框 -->
  328. <el-dialog
  329. title="导入失败"
  330. :visible.sync="exportErrorDioalogVisible"
  331. width="60%"
  332. >
  333. <el-table :data="errorData" style="width: 100%">
  334. <el-table-column label="名称" prop="name"> </el-table-column>
  335. <el-table-column label="型号" prop="modeType"> </el-table-column>
  336. <el-table-column label="编号" prop="codeNo"> </el-table-column>
  337. <el-table-column label="物料组" prop="code"> </el-table-column>
  338. <el-table-column label="失败原因" prop="remark"> </el-table-column>
  339. </el-table>
  340. <span slot="footer" class="dialog-footer">
  341. <el-button @click="exportErrorDioalogVisible = false">取 消</el-button>
  342. <el-button type="primary" @click="exportErrorDioalogVisible = false"
  343. >确 定</el-button
  344. >
  345. </span>
  346. </el-dialog>
  347. <importDialog
  348. :defModule="moudleName"
  349. ref="importDialogRef"
  350. :fileUrl="'/main/category/downLoadTemplate'"
  351. fileName="产品_物品导入模板"
  352. @success="reload"
  353. />
  354. <!-- 产品管理 -->
  355. <BomDetailsPop ref="bomDrawer"></BomDetailsPop>
  356. <DialogMoveTo ref="DialogMoveToRef" @success="success"></DialogMoveTo>
  357. <warehouseDialog
  358. ref="warehouseDialogRef"
  359. @success="success"
  360. ></warehouseDialog>
  361. <process-submit-dialog
  362. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  363. v-if="processSubmitDialogFlag"
  364. ref="processSubmitDialogRef"
  365. :custom-submit="submitCategoryPublish"
  366. @reload="handleProcessReload"
  367. ></process-submit-dialog>
  368. </div>
  369. </template>
  370. <script>
  371. import {
  372. getMaterialList,
  373. removeMaterial,
  374. importCategorySparePart,
  375. exportFile,
  376. changeOnOff,
  377. publishCategory
  378. } from '@/api/material/list.js';
  379. import { getBomGetById } from '@/api/material/BOM.js';
  380. import MaterialModal from './MaterialModal.vue';
  381. import ParamEdit from '@/views/technology/productParam/components/user-edit.vue';
  382. import mouldDialog from './mouldDialog';
  383. import linkMaterialDialog from './link-material-dialog.vue';
  384. import goodsAllocation from './goodsAllocation.vue';
  385. import { parameterGetByCode } from '@/api/system/dictionary/index.js';
  386. import BomDetailsPop from '../../BOMmanage/detailsPop.vue';
  387. import dictMixins from '@/mixins/dictMixins';
  388. import aridRegion from './aridRegion';
  389. import importDialog from '@/components/upload/import-dialogNew.vue';
  390. import { fieldModel } from '@/api/codeManagement';
  391. import DialogMoveTo from './DialogMoveTo.vue';
  392. import warehouseDialog from './warehouseDialog.vue';
  393. import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
  394. import tabMixins from '@/mixins/tableColumnsMixin';
  395. import { produceTypeList } from '@/enum/dict.js';
  396. import request from '@/utils/request';
  397. import { download } from '@/utils/file';
  398. import { getByCode } from '@/api/system/dictionary-data';
  399. /*const attributeList = [
  400. {
  401. label: '总装',
  402. value: 1
  403. },
  404. {
  405. label: '部件',
  406. value: 2
  407. },
  408. {
  409. label: '零件',
  410. value: 3
  411. },
  412. {
  413. label: '原材料',
  414. value: 4
  415. }
  416. ];*/
  417. const measureTypeList = [
  418. {
  419. label: '数量',
  420. value: 1
  421. },
  422. {
  423. label: '重量',
  424. value: 2
  425. },
  426. {
  427. label: '体积',
  428. value: 3
  429. },
  430. {
  431. label: '容积',
  432. value: 4
  433. },
  434. {
  435. label: '面积',
  436. value: 5
  437. }
  438. ];
  439. export default {
  440. mixins: [dictMixins, tabMixins],
  441. components: {
  442. importDialog,
  443. MaterialModal,
  444. ParamEdit,
  445. mouldDialog,
  446. linkMaterialDialog,
  447. goodsAllocation,
  448. aridRegion,
  449. BomDetailsPop,
  450. DialogMoveTo,
  451. warehouseDialog,
  452. processSubmitDialog
  453. },
  454. props: {
  455. // 物料组id
  456. currentId: [Number, String],
  457. data: [Array, Object],
  458. rootId: [Number, String],
  459. rootTreeId: [Number, String],
  460. lyType: [String],
  461. oneProduct: Boolean,
  462. currentData: Object,
  463. //table-cacheKeyUrl
  464. cacheKeyUrl: String
  465. },
  466. data() {
  467. return {
  468. attributeList: [],
  469. exportLoading: false,
  470. moudleName: 'mainCategory',
  471. currentPage: 1,
  472. errorData: [],
  473. exportErrorDioalogVisible: false,
  474. pagination: {
  475. total: 0
  476. },
  477. bomShow: false,
  478. whereData: {},
  479. pageShow: false,
  480. // 表格列配置
  481. columns: [
  482. {
  483. width: 45,
  484. type: 'selection',
  485. columnKey: 'selection',
  486. align: 'center',
  487. selectable: (row) => !this.isApproving(row)
  488. },
  489. {
  490. columnKey: 'index',
  491. type: 'index',
  492. width: 50,
  493. align: 'center',
  494. showOverflowTooltip: true,
  495. label: '序号'
  496. },
  497. {
  498. prop: 'code',
  499. label: '编码',
  500. align: 'center',
  501. showOverflowTooltip: true,
  502. sortable: true,
  503. minWidth: 110,
  504. slot: 'code'
  505. },
  506. {
  507. prop: 'name',
  508. label: '名称',
  509. align: 'center',
  510. showOverflowTooltip: true,
  511. minWidth: 110,
  512. slot: 'name'
  513. },
  514. {
  515. prop: 'categoryLevelPath',
  516. label: '分类',
  517. align: 'center',
  518. showOverflowTooltip: true
  519. },
  520. // {
  521. // prop: 'categoryLevelPath',
  522. // label: 'BOM状态',
  523. // align: 'center',
  524. // showOverflowTooltip: true,
  525. // formatter: (row, column) => {
  526. // return row.isUnpack == 1 ? '是' : '否';
  527. // }
  528. // },
  529. {
  530. prop: 'brandNum',
  531. align: 'center',
  532. label: '牌号',
  533. showOverflowTooltip: true
  534. },
  535. {
  536. prop: 'modelType',
  537. label: '型号',
  538. align: 'center',
  539. showOverflowTooltip: true
  540. },
  541. {
  542. prop: 'specification',
  543. label: '规格',
  544. align: 'center',
  545. showOverflowTooltip: true
  546. },
  547. {
  548. prop: 'imgCode',
  549. label: '图号/件号',
  550. align: 'center',
  551. showOverflowTooltip: true
  552. },
  553. {
  554. prop: 'level',
  555. label: '级别',
  556. align: 'center',
  557. showOverflowTooltip: true
  558. },
  559. {
  560. prop: 'bomStatus',
  561. label: 'MBOM状态',
  562. align: 'center',
  563. minWidth: 120,
  564. formatter: (row, column) => {
  565. return row.bomStatus == 1 ? '有' : '无';
  566. },
  567. showOverflowTooltip: true
  568. },
  569. {
  570. prop: 'pBomStatus',
  571. label: 'PBOM状态',
  572. align: 'center',
  573. minWidth: 120,
  574. formatter: (row, column) => {
  575. return row.pbomStatus == 1 ? '有' : '无';
  576. },
  577. showOverflowTooltip: true
  578. },
  579. {
  580. prop: 'aBomStatus',
  581. label: 'ABOM状态',
  582. align: 'center',
  583. minWidth: 120,
  584. formatter: (row, column) => {
  585. return row.abomStatus == 1 ? '有' : '无';
  586. },
  587. showOverflowTooltip: true
  588. },
  589. {
  590. prop: 'isUnpack',
  591. label: '是否允许拆包',
  592. align: 'center',
  593. minWidth: 120,
  594. formatter: (row, column) => {
  595. return row.isUnpack == 1 ? '是' : '否';
  596. },
  597. showOverflowTooltip: true
  598. },
  599. {
  600. prop: 'isComeCheck',
  601. label: '是否采购来料检验',
  602. align: 'center',
  603. minWidth: 120,
  604. formatter: (row, column) => {
  605. return row.isComeCheck == 1 ? '是' : '否';
  606. },
  607. showOverflowTooltip: true
  608. },
  609. {
  610. prop: 'isOutsourcingCheck',
  611. label: '是否委外来料检验',
  612. align: 'center',
  613. minWidth: 120,
  614. formatter: (row, column) => {
  615. return row.isOutsourcingCheck == 1 ? '是' : '否';
  616. },
  617. showOverflowTooltip: true
  618. },
  619. {
  620. prop: 'measuringUnit',
  621. label: '计量单位',
  622. showOverflowTooltip: true,
  623. minWidth: 90
  624. },
  625. {
  626. prop: 'weightUnit',
  627. label: '重量单位',
  628. showOverflowTooltip: true,
  629. minWidth: 90
  630. },
  631. {
  632. prop: 'roughWeight',
  633. label: '毛重',
  634. showOverflowTooltip: true,
  635. minWidth: 90
  636. },
  637. {
  638. prop: 'netWeight',
  639. label: '净重',
  640. showOverflowTooltip: true,
  641. minWidth: 90
  642. },
  643. {
  644. prop: 'packingUnit',
  645. align: 'center',
  646. label: '包装单位',
  647. showOverflowTooltip: true
  648. },
  649. {
  650. prop: 'componentAttribute',
  651. slot: 'componentAttribute',
  652. align: 'center',
  653. label: '属性类型',
  654. showOverflowTooltip: true
  655. // formatter: (row, column) => {
  656. // return row?.produceType
  657. // ?.map((item) => {
  658. // {{row}}
  659. // return this.getDictValueFn(item);
  660. // })
  661. // ?.toString();
  662. // }
  663. },
  664. {
  665. prop: 'attributeType',
  666. align: 'center',
  667. label: '存货类型',
  668. showOverflowTooltip: true,
  669. formatter: (row, column) => {
  670. const item = this.attributeList.find(
  671. (item) => item[row.attributeType] !== undefined
  672. );
  673. return item ? item[row.attributeType] : null; // 如果找不到返回 null
  674. }
  675. },
  676. {
  677. prop: 'produceType',
  678. align: 'center',
  679. label: '生产类型',
  680. showOverflowTooltip: true,
  681. formatter: (row, column) => {
  682. return produceTypeList.find(
  683. (item) => item.value == row.produceType
  684. )?.label;
  685. }
  686. },
  687. {
  688. prop: 'measureType',
  689. align: 'center',
  690. label: '计量类型',
  691. showOverflowTooltip: true,
  692. formatter: (row, column) => {
  693. return measureTypeList.find(
  694. (item) => item.value == row.measureType
  695. )?.label;
  696. }
  697. },
  698. {
  699. prop: 'modelKey',
  700. label: '机型',
  701. align: 'center',
  702. minWidth: 150,
  703. showOverflowTooltip: true,
  704. formatter: (row, column) => {
  705. return row.modelKey
  706. ? row.modelKey
  707. .split(',')
  708. ?.map((item) => this.getDictValue('物品机型', item))
  709. .toString()
  710. : '';
  711. }
  712. },
  713. {
  714. prop: 'colorKey',
  715. label: '颜色',
  716. align: 'center',
  717. minWidth: 150,
  718. showOverflowTooltip: true,
  719. formatter: (row, column) => {
  720. return row.colorKey
  721. ? row.colorKey
  722. .split(',')
  723. ?.map((item) => this.getDictValue('物品颜色', item))
  724. .toString()
  725. : '';
  726. }
  727. },
  728. {
  729. prop: 'createTime',
  730. label: '创建时间',
  731. align: 'center',
  732. showOverflowTooltip: true
  733. },
  734. {
  735. prop: 'createUserName',
  736. label: '创建人',
  737. align: 'center',
  738. showOverflowTooltip: true
  739. },
  740. {
  741. prop: 'isPublished',
  742. label: '发布状态',
  743. align: 'center',
  744. minWidth: 100,
  745. formatter: (row, column) => {
  746. return row.isPublished == 1 ? '已发布' : '未发布';
  747. },
  748. showOverflowTooltip: true
  749. },
  750. {
  751. prop: 'approveStatus',
  752. label: '审核状态',
  753. align: 'center',
  754. minWidth: 100,
  755. slot: 'approveStatus',
  756. showOverflowTooltip: true
  757. },
  758. {
  759. prop: 'isEnabled',
  760. align: 'center',
  761. label: '状态',
  762. slot: 'isEnabled',
  763. showOverflowTooltip: true,
  764. fixed: 'right',
  765. formatter: (row, column) => {
  766. return row.isEnabled === 0
  767. ? '停用'
  768. : row.isEnabled === 1
  769. ? '启用'
  770. : '';
  771. }
  772. }
  773. ],
  774. sxtList: [
  775. {
  776. label: '自制件',
  777. value: 1
  778. },
  779. {
  780. label: '采购件',
  781. value: 2
  782. },
  783. {
  784. label: '外协件',
  785. value: 3
  786. },
  787. {
  788. label: '受托件',
  789. value: 4
  790. }
  791. ],
  792. // newColumns: [],
  793. // 表格选中数据
  794. selection: [],
  795. // 是否显示编辑弹窗
  796. showEdit: false,
  797. id: null,
  798. materialEdit: false,
  799. paramEditShow: false,
  800. mouldShow: false,
  801. current: null,
  802. rowCurrent: null,
  803. isLoading: false,
  804. pageSize: this.$store.state.tablePageSize,
  805. isBatchPublish: true,
  806. processSubmitDialogFlag: false
  807. };
  808. },
  809. created: function () {
  810. getByCode('inventory_type').then((res) => {
  811. if (res.code === '0') {
  812. this.attributeList = res.data;
  813. }
  814. });
  815. this.getCategoryNeedApprove();
  816. // this.requestDict('生产类型');
  817. this.requestDict('物品机型');
  818. this.requestDict('物品颜色');
  819. this.getFieldModel();
  820. },
  821. activated() {
  822. this.getCategoryNeedApprove();
  823. },
  824. methods: {
  825. getCategoryNeedApprove() {
  826. return parameterGetByCode({
  827. code: 'category_need_approve'
  828. }).then((res) => {
  829. console.log(res.value, 'category_need_approve');
  830. this.isBatchPublish = res.value == 1 ? true : false;
  831. });
  832. },
  833. async changeEnable(row) {
  834. const res = await changeOnOff(row.id);
  835. if (res.code == 0) {
  836. this.$message({
  837. type: 'success',
  838. message: '修改成功',
  839. customClass: 'ele-message-border'
  840. });
  841. this.reload();
  842. }
  843. },
  844. onSortChange(e) {
  845. console.log(e, '99999999');
  846. let sort = {
  847. orderBy: e.order,
  848. sortName: e.prop
  849. };
  850. this.sort = sort;
  851. this.reload();
  852. },
  853. getDictValueFn(e) {
  854. // console.log(e,'3333333333333');
  855. if (e.length) {
  856. let arr = [];
  857. e.map((v) => {
  858. arr.push(this.findFn(v)?.label);
  859. });
  860. return arr.join(',');
  861. } else {
  862. return '';
  863. }
  864. // let a =
  865. // return a?.label||''
  866. },
  867. findFn(e) {
  868. return this.sxtList.find((item) => item.value == Number(e));
  869. },
  870. toBomManager(row) {
  871. let rowData = {
  872. categoryId: row.id,
  873. categoryName: row.name,
  874. code: row.code,
  875. rootPathIdParent: row.categoryLevelPathIdParent,
  876. isProduct: row.isProduct == 1
  877. };
  878. this.$refs.bomDrawer.open(rowData);
  879. },
  880. //采购
  881. moveTo() {
  882. if (this.hasApprovingSelection()) {
  883. return;
  884. }
  885. this.$refs.DialogMoveToRef.open(this.selection);
  886. },
  887. //仓库
  888. warehouseOpen() {
  889. if (this.hasApprovingSelection()) {
  890. return;
  891. }
  892. this.$refs.warehouseDialogRef.open(this.selection);
  893. },
  894. successUpload(response) {
  895. this.isLoading = false;
  896. },
  897. errorUpload(response) {
  898. this.isLoading = false;
  899. },
  900. // 上传备品备件
  901. beforeUpload(file) {
  902. if (file.size / 1024 / 1024 > this.size) {
  903. this.$message.error(`大小不能超过 ${this.size}MB`);
  904. return false;
  905. }
  906. if (this.limit > 0 && this.fileList.length === this.limit) {
  907. this.$message.error(`最多上传 ${this.limit}个文件`);
  908. return false;
  909. }
  910. let formData = new FormData();
  911. formData.append('file', file);
  912. this.isLoading = true;
  913. return importCategorySparePart(formData).then((res) => {
  914. if (res.data.length > 0) {
  915. this.exportErrorDioalogVisible = true;
  916. this.errorData = res.data;
  917. } else {
  918. this.$message.success('导入成功!');
  919. }
  920. this.isLoading = false;
  921. return false;
  922. });
  923. },
  924. /* 表格数据源 */
  925. hasCurrentCategory() {
  926. return (
  927. this.currentId !== undefined &&
  928. this.currentId !== null &&
  929. this.currentId !== ''
  930. );
  931. },
  932. getCategoryParams(params = {}) {
  933. return {
  934. ...params,
  935. categoryLevelId: this.currentId
  936. };
  937. },
  938. async datasource({ page, limit, where, order }) {
  939. this.currentPage = page;
  940. if (!this.hasCurrentCategory()) {
  941. return {
  942. pageNum: page,
  943. current: page,
  944. size: limit,
  945. count: 0,
  946. list: []
  947. };
  948. }
  949. const params = this.getCategoryParams({
  950. pageNum: page,
  951. size: limit,
  952. ...this.sort,
  953. ...where
  954. });
  955. this.whereData = params;
  956. return getMaterialList(params);
  957. },
  958. /* 刷新表格 */
  959. reload(where) {
  960. if (!this.hasCurrentCategory()) {
  961. return;
  962. }
  963. let labs = this.getCategoryParams({
  964. page: 1,
  965. where: where
  966. });
  967. this.whereData = labs;
  968. this.$refs.table.reload(
  969. this.getCategoryParams({
  970. page: 1,
  971. where: where
  972. })
  973. );
  974. },
  975. /* 刷新表格 */
  976. reloadNew(where) {
  977. if (!this.hasCurrentCategory()) {
  978. return;
  979. }
  980. let labs = this.getCategoryParams({
  981. page: 1,
  982. where: where
  983. });
  984. this.whereData = labs;
  985. this.$refs.table.reload(
  986. this.getCategoryParams({
  987. page: this.currentPage,
  988. where: where
  989. })
  990. );
  991. },
  992. getFieldModel() {
  993. fieldModel({ relevance: 't_main_category' }).then((res) => {
  994. const privateColumn = [
  995. {
  996. columnKey: 'action',
  997. label: '操作',
  998. width: 300,
  999. align: 'center',
  1000. resizable: false,
  1001. slot: 'action',
  1002. fixed: 'right'
  1003. }
  1004. ];
  1005. let newRes = res.map((m) => {
  1006. return {
  1007. prop: 'extField.' + m.prop,
  1008. label: m.label,
  1009. align: 'center',
  1010. showOverflowTooltip: true
  1011. };
  1012. });
  1013. this.columns = [...this.columns, ...newRes, ...privateColumn];
  1014. this.getTabColumns();
  1015. this.$forceUpdate();
  1016. });
  1017. },
  1018. publish(row) {
  1019. if (this.isBatchPublish) {
  1020. this.submitApprove(row);
  1021. return;
  1022. }
  1023. const loading = this.$loading({ lock: true });
  1024. publishCategory({ categoryId: row.id })
  1025. .then((res) => {
  1026. this.$message.success(res.message || '发布成功');
  1027. this.reloadNew();
  1028. })
  1029. .finally(() => {
  1030. loading.close();
  1031. });
  1032. },
  1033. submitApprove(row) {
  1034. if (!row || !row.id) {
  1035. return;
  1036. }
  1037. this.processSubmitDialogFlag = true;
  1038. this.$nextTick(() => {
  1039. const userInfo = this.$store.state.user.info || {};
  1040. const params = {
  1041. businessId: row.id,
  1042. businessKey: 'category_need_approve',
  1043. formCreateUserId: row.createUserId || userInfo.userId || userInfo.id,
  1044. variables: {
  1045. businessCode: row.code,
  1046. businessName: row.name,
  1047. businessType: this.getCategoryBusinessType(row)
  1048. }
  1049. };
  1050. this.$refs.processSubmitDialogRef.init(params);
  1051. });
  1052. },
  1053. getCategoryBusinessType(row) {
  1054. return row.categoryLevelPath || row.categoryName || '物品发布';
  1055. },
  1056. submitCategoryPublish(businessId, form) {
  1057. return publishCategory({
  1058. categoryId: businessId,
  1059. ...form
  1060. });
  1061. },
  1062. handleProcessReload() {
  1063. this.reloadNew();
  1064. },
  1065. /* 显示编辑 */
  1066. batchPublish() {
  1067. if (!this.selection.length) {
  1068. this.$message.warning('请先勾选要发布的数据');
  1069. return;
  1070. }
  1071. if (this.hasApprovingSelection()) {
  1072. return;
  1073. }
  1074. const publishedList = this.selection.filter((item) => item.isPublished == 1);
  1075. if (publishedList.length) {
  1076. const publishedNames = publishedList
  1077. .map((item) => item.name || item.code || item.categoryId || item.id)
  1078. .filter(Boolean)
  1079. .join('、');
  1080. this.$message.warning(
  1081. `勾选的数据中【${publishedNames}】已发布,不能继续发布`
  1082. );
  1083. return;
  1084. }
  1085. const categoryIds = this.selection
  1086. .map((item) => item.categoryId || item.id)
  1087. .filter((id) => id !== undefined && id !== null && id !== '');
  1088. if (!categoryIds.length) {
  1089. this.$message.warning('未获取到可发布数据');
  1090. return;
  1091. }
  1092. this.$confirm(`确定要发布选中的 ${categoryIds.length} 条数据吗?`, '提示', {
  1093. confirmButtonText: '确定',
  1094. cancelButtonText: '取消',
  1095. type: 'warning'
  1096. })
  1097. .then(() => {
  1098. const loading = this.$loading({ lock: true });
  1099. publishCategory({ categoryIds })
  1100. .then((res) => {
  1101. this.$message.success(res.message || '发布成功');
  1102. this.reloadNew();
  1103. })
  1104. .finally(() => {
  1105. loading.close();
  1106. });
  1107. })
  1108. .catch(() => {
  1109. // 用户取消发布
  1110. });
  1111. },
  1112. openEdit(row, status) {
  1113. console.log(status, this.currentData, 'status');
  1114. let isUpdate;
  1115. let readOnly = false;
  1116. if (status == 2) {
  1117. isUpdate = 0;
  1118. } else if (status == 3) {
  1119. // 详情模式:只读
  1120. isUpdate = 0;
  1121. readOnly = true;
  1122. } else {
  1123. isUpdate = 1;
  1124. }
  1125. this.$router.push({
  1126. path: '/material/product/detail',
  1127. query: {
  1128. lyType: this.lyType,
  1129. id: row.id ? row.id : null,
  1130. status: status,
  1131. rootId: this.rootId,
  1132. isUpdate: isUpdate,
  1133. readOnly: readOnly,
  1134. oneProduct: this.oneProduct,
  1135. t: new Date().getTime(),
  1136. rootTreeId: this.rootTreeId,
  1137. ...this.currentData
  1138. }
  1139. });
  1140. },
  1141. /* 删除 */
  1142. remove(row) {
  1143. const loading = this.$loading({ lock: true });
  1144. removeMaterial(row.id)
  1145. .then((msg) => {
  1146. this.$refs.table.reload({
  1147. page: 1,
  1148. categoryLevelId: this.currentId
  1149. });
  1150. loading.close();
  1151. })
  1152. .catch((e) => {
  1153. loading.close();
  1154. });
  1155. },
  1156. openMaterial(row) {
  1157. this.current = row;
  1158. this.materialEdit = true;
  1159. this.$refs.materialRefs.$refs.form &&
  1160. this.$refs.materialRefs.$refs.form.clearValidate();
  1161. },
  1162. openParam(row) {
  1163. this.paramEditShow = true;
  1164. this.current = row;
  1165. this.$refs.paramRefs.$refs.form &&
  1166. this.$refs.paramRefs.$refs.form.clearValidate();
  1167. },
  1168. openMould(row) {
  1169. this.current = row;
  1170. this.mouldShow = true;
  1171. this.$refs.mouldRefs.$refs.form &&
  1172. this.$refs.mouldRefs.$refs.form.clearValidate();
  1173. },
  1174. handleLink(type) {
  1175. if (!this.rowCurrent) {
  1176. return this.$message.error(
  1177. this.rootTreeId == 9
  1178. ? '请选择产品!'
  1179. : this.rootTreeId == 4
  1180. ? '请选择设备!'
  1181. : ''
  1182. );
  1183. }
  1184. this.$refs.linkMaterialDialogRef.open(type, this.rowCurrent);
  1185. },
  1186. success() {
  1187. this.reload();
  1188. },
  1189. hasApproveStatus(row) {
  1190. return (
  1191. row &&
  1192. Object.prototype.hasOwnProperty.call(row, 'approveStatus') &&
  1193. row.approveStatus !== null &&
  1194. row.approveStatus !== undefined &&
  1195. row.approveStatus !== ''
  1196. );
  1197. },
  1198. isApproving(row) {
  1199. if (!this.hasApproveStatus(row)) {
  1200. return false;
  1201. }
  1202. return Number(row.approveStatus) === 1 || row.approveStatus === '审核中';
  1203. },
  1204. isApprovePassed(row) {
  1205. if (!this.hasApproveStatus(row)) {
  1206. return false;
  1207. }
  1208. return Number(row.approveStatus) === 2 || row.approveStatus === '已审核';
  1209. },
  1210. hasApprovingSelection() {
  1211. if (this.selection.some((item) => this.isApproving(item))) {
  1212. this.$message.warning('审核中的数据只能查看详情');
  1213. return true;
  1214. }
  1215. return false;
  1216. },
  1217. getApproveStatusTagType(row) {
  1218. if (!this.hasApproveStatus(row)) {
  1219. return '';
  1220. }
  1221. return (
  1222. {
  1223. 0: 'info',
  1224. 1: 'warning',
  1225. 2: 'success',
  1226. 3: 'danger'
  1227. }[Number(row.approveStatus)] || ''
  1228. );
  1229. },
  1230. getApproveStatusText(row) {
  1231. if (!this.hasApproveStatus(row)) {
  1232. return '';
  1233. }
  1234. return {
  1235. 0: '未提交',
  1236. 1: '审核中',
  1237. 2: '已审核',
  1238. 3: '审核不通过'
  1239. }[Number(row.approveStatus)] || row.approveStatus;
  1240. },
  1241. handAllocation(row) {
  1242. this.$refs.allocationRef.open(row);
  1243. },
  1244. handleAridRegion(row) {
  1245. this.$refs.aridRegionRef.open(row);
  1246. },
  1247. uploadFile() {
  1248. this.$refs.importDialogRef.open();
  1249. },
  1250. /** 导出按钮操作 */
  1251. handleExport() {
  1252. const data = this.whereData;
  1253. if (!data || Object.keys(data).length === 0 || !data.categoryLevelId) {
  1254. this.$message.warning('请选择物品类别');
  1255. return;
  1256. }
  1257. this.exportLoading = true;
  1258. request
  1259. .post('/main/category/export', data, {
  1260. responseType: 'blob'
  1261. })
  1262. .then((res) => {
  1263. debugger;
  1264. download(res.data, '产品/物品数据.xlsx');
  1265. })
  1266. .catch((e) => {
  1267. console.error(e);
  1268. })
  1269. .finally(() => {
  1270. this.exportLoading = false;
  1271. });
  1272. /*exportFile(this.whereData);
  1273. console.log(this.whereData, 'whereForm');*/
  1274. },
  1275. /** 下载模板操作 */
  1276. importTemplate() {
  1277. importTemplate(this.whereForm).then((res) => {
  1278. this.$message.success('模板下载成功');
  1279. });
  1280. }
  1281. },
  1282. watch: {
  1283. // 监听物料组id变化
  1284. currentId() {
  1285. if (this.hasCurrentCategory()) {
  1286. this.reload();
  1287. }
  1288. },
  1289. $route: {
  1290. handler(route) {
  1291. this.pageShow = false;
  1292. if (route.query && route.query.isWt) {
  1293. getBomGetById(route.query.businessId).then((res) => {
  1294. let rowData = {
  1295. categoryId: res.data.categoryId,
  1296. categoryName: res.data.name,
  1297. code: res.data.categoryCode,
  1298. rootPathIdParent: res.data.rootCategoryLevelId,
  1299. isProduct: res.data.rootCategoryLevelId == 9 ? true : false,
  1300. versions: res.data.versions,
  1301. bomType: res.data.bomType,
  1302. isWt: true,
  1303. isBtn: route.query.isBtn
  1304. };
  1305. this.$nextTick(() => {
  1306. this.$refs.bomDrawer.open(rowData);
  1307. this.pageShow = true;
  1308. });
  1309. });
  1310. } else {
  1311. this.pageShow = true;
  1312. }
  1313. },
  1314. immediate: true
  1315. }
  1316. }
  1317. };
  1318. </script>
  1319. <style lang="scss" scoped>
  1320. .upload {
  1321. display: inline-block;
  1322. width: 100px;
  1323. margin-left: 10px;
  1324. }
  1325. </style>