mould-list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. <template>
  2. <div>
  3. <mould-search
  4. ref="searchRef"
  5. @search="reload"
  6. :networkCounts="networkCounts"
  7. >
  8. </mould-search>
  9. <!-- 数据表格 -->
  10. <ele-pro-table
  11. ref="table"
  12. :pageSizes="tablePageSizes"
  13. :columns="columns"
  14. :page-size="defPageSize"
  15. :datasource="datasource"
  16. height="calc(100vh - 320px)"
  17. full-height="calc(100vh - 115px)"
  18. tool-class="ele-toolbar-form"
  19. cache-key="systemOrgUserTable"
  20. @select="selectChange"
  21. @select-all="changeSelectAll"
  22. >
  23. <!-- 表头工具栏 -->
  24. <template v-slot:toolbar>
  25. <el-button
  26. size="small"
  27. type="primary"
  28. icon="el-icon-plus"
  29. class="ele-btn-icon"
  30. @click="add"
  31. >
  32. 新建
  33. </el-button>
  34. <el-button
  35. size="small"
  36. icon="el-icon-download"
  37. class="ele-btn-icon"
  38. @click="btnExport"
  39. >
  40. 导出
  41. </el-button>
  42. <el-button
  43. :disabled="checkRadioData.length == 0"
  44. size="small"
  45. icon="el-icon-set-up"
  46. class="ele-btn-icon"
  47. @click="allPrinting()"
  48. >
  49. 打印条码
  50. </el-button>
  51. <el-button
  52. size="small"
  53. :disabled="checkRadioData.length == 0"
  54. icon="el-icon-thumb"
  55. class="ele-btn-icon"
  56. @click="moveTo(checkRadioData, 'person')"
  57. v-if="$hasPermission('main:substance:update')"
  58. >
  59. 设置片区负责人
  60. </el-button>
  61. <el-button
  62. size="small"
  63. :disabled="checkRadioData.length == 0"
  64. icon="el-icon-s-tools"
  65. class="ele-btn-icon"
  66. @click="batchSettings(1)"
  67. v-if="$hasPermission('main:substance:update')"
  68. >
  69. 设置权属部门
  70. </el-button>
  71. <el-button
  72. size="small"
  73. :disabled="checkRadioData.length == 0"
  74. icon="el-icon-setting"
  75. class="ele-btn-icon"
  76. @click="batchSettings(2)"
  77. v-if="$hasPermission('main:substance:update')"
  78. >
  79. 设置使用单位
  80. </el-button>
  81. <el-button
  82. size="small"
  83. :disabled="checkRadioData.length == 0"
  84. icon="el-icon-s-tools"
  85. class="ele-btn-icon"
  86. type="danger"
  87. @click="setStatus(1)"
  88. v-if="$hasPermission('main:substance:stop')"
  89. >
  90. 批量停机
  91. </el-button>
  92. <el-button
  93. size="small"
  94. :disabled="checkRadioData.length == 0"
  95. icon="el-icon-setting"
  96. class="ele-btn-icon"
  97. @click="setStatus(2)"
  98. v-if="$hasPermission('main:substance:run')"
  99. >
  100. 批量运行
  101. </el-button>
  102. <el-button
  103. size="small"
  104. :disabled="checkRadioData.length == 0"
  105. icon="el-icon-s-home"
  106. class="ele-btn-icon"
  107. @click="setFactory"
  108. v-if="$hasPermission('main:substance:update')"
  109. >
  110. 设置所属工厂
  111. </el-button>
  112. </template>
  113. <!-- 编码列 -->
  114. <template v-slot:code="{ row }">
  115. <el-link type="primary" :underline="false" @click="details(row)">
  116. {{ row.code }}
  117. </el-link>
  118. </template>
  119. <!-- 牌号列 -->
  120. <template v-slot:brandNum="{ row }">
  121. <div>
  122. {{ row.category.brandNum }}
  123. </div>
  124. </template>
  125. <!-- 型号列 -->
  126. <template v-slot:modelType="{ row }">
  127. <div>
  128. {{ row.category.modelType }}
  129. </div>
  130. </template>
  131. <!-- 分类列 -->
  132. <template v-slot:categoryLevelPath="{ row }">
  133. <div>
  134. {{ row.category.categoryLevelPath }}
  135. </div>
  136. </template>
  137. <!-- 操作列 -->
  138. <template v-slot:action="{ row }">
  139. <el-link
  140. type="primary"
  141. :underline="false"
  142. icon="el-icon-edit"
  143. @click="goEdit(row)"
  144. >
  145. 编辑
  146. </el-link>
  147. <el-link type="primary" @click="$refs.accountingLedgerListRef.open(row)"
  148. >表计BOM</el-link
  149. >
  150. <el-link type="primary" @click="handelBOM(row)">BOM</el-link>
  151. </template>
  152. </ele-pro-table>
  153. <print ref="printRef"></print>
  154. <printSr ref="printSrRef"></printSr>
  155. <printTg ref="printTgRef"></printTg>
  156. <BomDetailsPop ref="bomDrawer"></BomDetailsPop>
  157. <batchSetDialog ref="batchSetRef" @success="sucesstion" />
  158. <batchSetFactory ref="batchSetFactoryRef" @success="sucesstion" />
  159. <DialogMoveto ref="movetoRef" @success="sucesstion" />
  160. <accountingLedgerList ref="accountingLedgerListRef"></accountingLedgerList>
  161. </div>
  162. </template>
  163. <script>
  164. import accountingLedgerList from '@/views/ledgerAssets/components/accountingLedgerList.vue';
  165. import batchSetDialog from '@/views/ledgerAssets/equipment/components/batchSetDialog.vue';
  166. import batchSetFactory from '@/views/ledgerAssets/equipment/components/batchSetFactory.vue';
  167. import DialogMoveto from '@/views/ledgerAssets/equipment/components/DialogMoveTo.vue';
  168. import print from '@/views/ledgerAssets/components/print.vue';
  169. import printSr from '@/views/ledgerAssets/components/printSr';
  170. import printTg from '@/views/ledgerAssets/components/printTg';
  171. import { getByCode } from '@/api/system/dictionary-data';
  172. import {
  173. businessStatus,
  174. networkStatus,
  175. sourceStatus
  176. } from '@/utils/dict/warehouse';
  177. import MouldSearch from '@/views/ledgerAssets/equipment/components/equipment-search.vue';
  178. import { getAssetList, downloadAsset, batchStop, batchRun } from '@/api/ledgerAssets';
  179. import dictMixins from '@/mixins/dictMixins';
  180. import axios from 'axios';
  181. import {
  182. API_BASE_URL,
  183. TOKEN_HEADER_NAME,
  184. LAYOUT_PATH
  185. } from '@/config/setting';
  186. import { download } from '@/utils/file';
  187. import { getToken, setToken } from '@/utils/token-util';
  188. import BomDetailsPop from '@/views/ledgerAssets/equipment/detailsPop.vue';
  189. export default {
  190. components: {
  191. MouldSearch,
  192. print,
  193. printSr,
  194. printTg,
  195. BomDetailsPop,
  196. DialogMoveto,
  197. batchSetDialog,
  198. batchSetFactory,
  199. accountingLedgerList
  200. },
  201. mixins: [dictMixins],
  202. props: {
  203. // 类别id
  204. categoryId: [Number, String],
  205. rootId: [Number, String]
  206. },
  207. data() {
  208. return {
  209. QRvisible: false,
  210. businessStatus,
  211. networkStatus,
  212. assetLevel: [],
  213. networkCounts: {},
  214. isConsumer: false,
  215. // 表格列配置
  216. columns: [
  217. {
  218. width: 45,
  219. type: 'selection',
  220. columnKey: 'selection',
  221. align: 'center'
  222. },
  223. {
  224. columnKey: 'index',
  225. type: 'index',
  226. label: '序号',
  227. width: 55,
  228. align: 'center',
  229. showOverflowTooltip: true,
  230. fixed: 'left'
  231. },
  232. {
  233. columnKey: 'code',
  234. prop: 'code',
  235. slot: 'code',
  236. label: '编码',
  237. showOverflowTooltip: true,
  238. minWidth: 180
  239. },
  240. {
  241. prop: 'category.name',
  242. label: '名称',
  243. showOverflowTooltip: true,
  244. minWidth: 110
  245. },
  246. {
  247. prop: 'fixCode',
  248. label: '固资编码',
  249. showOverflowTooltip: true,
  250. minWidth: 110
  251. },
  252. {
  253. prop: 'codeNumber',
  254. label: '编号',
  255. showOverflowTooltip: true,
  256. minWidth: 110
  257. },
  258. {
  259. prop: 'category.modelType',
  260. label: '型号',
  261. showOverflowTooltip: true,
  262. minWidth: 110
  263. },
  264. {
  265. prop: 'category.specification',
  266. label: '规格',
  267. showOverflowTooltip: true,
  268. minWidth: 110
  269. },
  270. {
  271. prop: 'extInfo.cyTimes',
  272. label: '已冲压次数',
  273. showOverflowTooltip: true,
  274. minWidth: 130
  275. },
  276. {
  277. prop: 'manufacturer',
  278. label: '制造厂',
  279. showOverflowTooltip: true,
  280. minWidth: 110
  281. },
  282. {
  283. prop: 'manufactureTime',
  284. label: '制造日期',
  285. showOverflowTooltip: true,
  286. minWidth: 110
  287. },
  288. {
  289. prop: 'createAccountsTime',
  290. label: '建账日期',
  291. showOverflowTooltip: true,
  292. minWidth: 110
  293. },
  294. {
  295. prop: 'postName',
  296. label: '使用单位',
  297. showOverflowTooltip: true,
  298. minWidth: 110
  299. },
  300. {
  301. prop: 'usePerson',
  302. label: '使用人',
  303. showOverflowTooltip: true,
  304. minWidth: 80
  305. },
  306. {
  307. prop: 'ownershipGroupName',
  308. label: '权属部门',
  309. showOverflowTooltip: true,
  310. minWidth: 110
  311. },
  312. {
  313. prop: 'areaPersonInChargeUserName',
  314. label: '片区负责人',
  315. showOverflowTooltip: true,
  316. minWidth: 150
  317. },
  318. {
  319. prop: 'repairUserName',
  320. label: '维修人',
  321. showOverflowTooltip: true,
  322. minWidth: 150
  323. },
  324. {
  325. prop: 'endTime',
  326. label: '有效期结束时间',
  327. showOverflowTooltip: true,
  328. minWidth: 150
  329. },
  330. {
  331. prop: 'source',
  332. label: '生命周期',
  333. showOverflowTooltip: true,
  334. minWidth: 110,
  335. formatter: (_row) => {
  336. return sourceStatus[_row.lifeCycle];
  337. }
  338. },
  339. {
  340. prop: 'level',
  341. label: '级别',
  342. showOverflowTooltip: true,
  343. minWidth: 110,
  344. formatter: (_row) => {
  345. if (_row.level) {
  346. return this.assetLevel.filter(
  347. (item) => item.id == _row.level
  348. )[0].name;
  349. } else {
  350. return '';
  351. }
  352. }
  353. },
  354. {
  355. prop: 'networkStatus',
  356. label: '网络状态',
  357. showOverflowTooltip: true,
  358. minWidth: 110,
  359. formatter: (_row) => {
  360. if (_row.networkStatus) {
  361. return this.networkStatus.filter(
  362. (item) => item.code == _row.networkStatus
  363. )[0].label;
  364. } else {
  365. return '离线';
  366. }
  367. }
  368. },
  369. {
  370. prop: 'status',
  371. label: '状态',
  372. showOverflowTooltip: true,
  373. minWidth: 110,
  374. formatter: (_row) => {
  375. if (_row.status) {
  376. return this.businessStatus.filter(
  377. (item) => item.code == _row.status
  378. )[0].label;
  379. } else {
  380. return '空闲';
  381. }
  382. }
  383. },
  384. {
  385. prop: 'runStatus',
  386. label: '运行状态',
  387. showOverflowTooltip: true,
  388. minWidth: 110,
  389. formatter: (_row) => {
  390. return _row.runStatus == 5 ? '停机' : '运行';
  391. }
  392. },
  393. {
  394. prop: 'factoryName',
  395. label: '所属工厂',
  396. showOverflowTooltip: true,
  397. minWidth: 110
  398. },
  399. {
  400. prop: 'pathName',
  401. label: '位置',
  402. showOverflowTooltip: true,
  403. minWidth: 110,
  404. formatter: (_row) => {
  405. const positionDetail =
  406. _row.position &&
  407. _row.position.length != 0 &&
  408. _row.position[0].detailPosition
  409. ? _row.position[0].detailPosition
  410. : '-';
  411. return _row.deviceLocationName
  412. ? _row.deviceLocationName + '-' + positionDetail
  413. : '';
  414. }
  415. },
  416. {
  417. columnKey: 'action',
  418. slot: 'action',
  419. label: '操作',
  420. minWidth: 180,
  421. fixed: 'right'
  422. }
  423. ],
  424. checkRadioData: []
  425. };
  426. },
  427. computed: {
  428. clientEnvironmentId() {
  429. return this.$store.state.user.info.clientEnvironmentId;
  430. }
  431. },
  432. created() {
  433. this.requestDict('生命周期');
  434. this.getAssetLevelOptions();
  435. },
  436. methods: {
  437. // 刷新回调
  438. sucesstion(is) {
  439. console.log(is);
  440. if (is) {
  441. this.reload();
  442. }
  443. this.checkRadioData = [];
  444. },
  445. // 移动到
  446. moveTo(arr, type) {
  447. this.$refs.movetoRef.open(arr, this.current, type);
  448. },
  449. batchSettings(type) {
  450. let ids = this.checkRadioData.map((item) => {
  451. return item.id;
  452. });
  453. this.$refs.batchSetRef.open(type, ids);
  454. console.log(this.checkRadioData, 'checkRadioData 123');
  455. },
  456. allPrinting() {
  457. if (this.clientEnvironmentId == 2) {
  458. this.$refs.printSrRef.open(this.checkRadioData);
  459. } else if (this.clientEnvironmentId == 3) {
  460. this.$refs.printTgRef.open(this.checkRadioData);
  461. } else {
  462. this.$refs.printRef.open(this.checkRadioData);
  463. }
  464. },
  465. // 全选
  466. changeSelectAll(arr) {
  467. console.log(arr);
  468. if (arr.length != 0) {
  469. this.checkRadioData = arr;
  470. } else {
  471. this.checkRadioData = [];
  472. }
  473. },
  474. selectChange(selection, row) {
  475. if (selection.length != 0) {
  476. this.checkRadioData = selection;
  477. } else {
  478. this.checkRadioData = [];
  479. }
  480. },
  481. setStatus(type) {
  482. let api = type == 1 ? batchStop : batchRun;
  483. api(this.checkRadioData.map((item) => item.id)).then((res) => {
  484. this.$message.success('操作成功');
  485. this.sucesstion(true);
  486. });
  487. },
  488. setFactory() {
  489. this.$refs.batchSetFactoryRef.open(this.checkRadioData);
  490. },
  491. // 获取资产级别下拉
  492. async getAssetLevelOptions() {
  493. let { data } = await getByCode('asset_level');
  494. this.assetLevel =
  495. data.length > 0
  496. ? data.map((item) => {
  497. return {
  498. name: Object.keys(item)[0],
  499. id: item[Object.keys(item)[0]]
  500. };
  501. })
  502. : [];
  503. },
  504. // 跳转到详情页
  505. add() {
  506. this.$router.push({
  507. path: '/ledgerAssets/mould/edit'
  508. });
  509. },
  510. /* 表格数据源 */
  511. datasource({ page, limit, where, order }) {
  512. return getAssetList({
  513. ...where,
  514. ...order,
  515. pageNum: page,
  516. size: limit,
  517. categoryLevelId: this.categoryId,
  518. rootCategoryLevelId: this.rootId
  519. });
  520. },
  521. /* 刷新表格 */
  522. reload(where) {
  523. this.$refs.table.reload({ pageNum: 1, where: where });
  524. },
  525. // 跳转到详情页
  526. details({ id, code }) {
  527. this.$router.push({
  528. path: '/ledgerAssets/mould/detail',
  529. query: {
  530. id,
  531. code
  532. }
  533. });
  534. },
  535. // 跳转到编辑页
  536. goEdit({ id }) {
  537. console.log(id);
  538. this.$router.push({
  539. path: '/ledgerAssets/mould/edit',
  540. query: {
  541. id
  542. }
  543. });
  544. },
  545. // 导出
  546. btnExport() {
  547. let params = {
  548. ...this.$refs.searchRef.where,
  549. exportType: 3,
  550. categoryLevelId: this.categoryId,
  551. rootCategoryLevelId: this.rootId
  552. };
  553. axios({
  554. url: `${API_BASE_URL}/main/asset/page/export`,
  555. method: 'post',
  556. responseType: 'blob',
  557. headers: {
  558. Authorization: getToken()
  559. },
  560. data: params
  561. }).then((res) => {
  562. download(res.data, '模具台账导出数据');
  563. });
  564. // downloadAsset(params, '模具台账导出数据');
  565. },
  566. handelBOM(row) {
  567. console.log(row, '111111111111111');
  568. let rowData = {
  569. categoryId: row.category.id,
  570. categoryName: row.categoryName,
  571. code: row.code,
  572. versions: row.versions,
  573. rootPathIdParent: row.category.categoryLevelPathIdParent,
  574. isProduct: true,
  575. bomType: '1',
  576. isTemp: row.isTemp
  577. };
  578. this.$refs.bomDrawer.open(rowData);
  579. }
  580. },
  581. watch: {
  582. // 监听类别id变化
  583. categoryId() {
  584. this.reload();
  585. }
  586. }
  587. };
  588. </script>
  589. <style lang="scss" scoped>
  590. .ele-btn-icon {
  591. margin-left: 20px;
  592. }
  593. </style>