mould-list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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. :columns="columns"
  13. :datasource="datasource"
  14. height="calc(100vh - 440px)"
  15. full-height="calc(100vh - 115px)"
  16. tool-class="ele-toolbar-form"
  17. cache-key="systemOrgUserTable"
  18. @select="selectChange"
  19. @select-all="changeSelectAll"
  20. >
  21. <!-- 表头工具栏 -->
  22. <template v-slot:toolbar>
  23. <el-button
  24. size="small"
  25. type="primary"
  26. icon="el-icon-plus"
  27. class="ele-btn-icon"
  28. @click="add"
  29. >
  30. 新建
  31. </el-button>
  32. <el-button
  33. size="small"
  34. icon="el-icon-download"
  35. class="ele-btn-icon"
  36. @click="btnExport"
  37. >
  38. 导出
  39. </el-button>
  40. <el-button
  41. :disabled="checkRadioData.length == 0"
  42. size="small"
  43. icon="el-icon-set-up"
  44. class="ele-btn-icon"
  45. @click="allPrinting()"
  46. >
  47. 打印条码
  48. </el-button>
  49. </template>
  50. <!-- 编码列 -->
  51. <template v-slot:code="{ row }">
  52. <el-link type="primary" :underline="false" @click="details(row)">
  53. {{ row.code }}
  54. </el-link>
  55. </template>
  56. <!-- 牌号列 -->
  57. <template v-slot:brandNum="{ row }">
  58. <div>
  59. {{ row.category.brandNum }}
  60. </div>
  61. </template>
  62. <!-- 型号列 -->
  63. <template v-slot:modelType="{ row }">
  64. <div>
  65. {{ row.category.modelType }}
  66. </div>
  67. </template>
  68. <!-- 分类列 -->
  69. <template v-slot:categoryLevelPath="{ row }">
  70. <div>
  71. {{ row.category.categoryLevelPath }}
  72. </div>
  73. </template>
  74. <!-- 操作列 -->
  75. <template v-slot:action="{ row }">
  76. <el-link
  77. type="primary"
  78. :underline="false"
  79. icon="el-icon-edit"
  80. @click="goEdit(row)"
  81. >
  82. 编辑
  83. </el-link>
  84. </template>
  85. </ele-pro-table>
  86. <print ref="printRef"></print>
  87. <printSr ref="printSrRef"></printSr>
  88. <printTg ref="printTgRef"></printTg>
  89. </div>
  90. </template>
  91. <script>
  92. import print from '@/views/ledgerAssets/components/print.vue';
  93. import printSr from '@/views/ledgerAssets/components/printSr';
  94. import printTg from '@/views/ledgerAssets/components/printTg';
  95. import { getByCode } from '@/api/system/dictionary-data';
  96. import { businessStatus, networkStatus } from '@/utils/dict/warehouse';
  97. import MouldSearch from './mould-search.vue';
  98. import { getAssetList, downloadAsset } from '@/api/ledgerAssets';
  99. import dictMixins from '@/mixins/dictMixins';
  100. import axios from 'axios';
  101. import {
  102. API_BASE_URL,
  103. TOKEN_HEADER_NAME,
  104. LAYOUT_PATH
  105. } from '@/config/setting';
  106. import { download } from '@/utils/file';
  107. import { getToken, setToken } from '@/utils/token-util';
  108. export default {
  109. components: { MouldSearch, print, printSr, printTg },
  110. mixins: [dictMixins],
  111. props: {
  112. // 类别id
  113. categoryId: [Number, String],
  114. rootId: [Number, String]
  115. },
  116. data() {
  117. return {
  118. QRvisible: false,
  119. businessStatus,
  120. networkStatus,
  121. assetLevel: [],
  122. networkCounts: {},
  123. isConsumer: false,
  124. // 表格列配置
  125. columns: [
  126. {
  127. width: 45,
  128. type: 'selection',
  129. columnKey: 'selection',
  130. align: 'center'
  131. },
  132. {
  133. columnKey: 'index',
  134. type: 'index',
  135. label: '序号',
  136. width: 55,
  137. align: 'center',
  138. showOverflowTooltip: true,
  139. fixed: 'left'
  140. },
  141. {
  142. columnKey: 'code',
  143. prop: 'code',
  144. slot: 'code',
  145. label: '编码',
  146. showOverflowTooltip: true,
  147. minWidth: 180
  148. },
  149. {
  150. prop: 'name',
  151. label: '名称',
  152. showOverflowTooltip: true,
  153. minWidth: 110
  154. },
  155. {
  156. prop: 'fixCode',
  157. label: '固资编码',
  158. showOverflowTooltip: true,
  159. minWidth: 110
  160. },
  161. {
  162. prop: 'postName',
  163. label: '使用岗位',
  164. showOverflowTooltip: true,
  165. minWidth: 110
  166. },
  167. {
  168. prop: 'codeNumber',
  169. label: '编号',
  170. showOverflowTooltip: true,
  171. minWidth: 110
  172. },
  173. {
  174. prop: 'category.modelType',
  175. label: '型号',
  176. showOverflowTooltip: true,
  177. minWidth: 110
  178. },
  179. {
  180. prop: 'category.specification',
  181. label: '规格',
  182. showOverflowTooltip: true,
  183. minWidth: 110
  184. },
  185. {
  186. prop: 'usePerson',
  187. label: '使用人',
  188. showOverflowTooltip: true,
  189. minWidth: 80
  190. },
  191. {
  192. prop: 'chargePerson',
  193. label: '负责人',
  194. showOverflowTooltip: true,
  195. minWidth: 80
  196. },
  197. {
  198. prop: 'endTime',
  199. label: '有效期结束时间',
  200. showOverflowTooltip: true,
  201. minWidth: 150
  202. },
  203. {
  204. prop: 'source',
  205. label: '生命周期',
  206. showOverflowTooltip: true,
  207. minWidth: 110
  208. },
  209. {
  210. prop: 'level',
  211. label: '级别',
  212. showOverflowTooltip: true,
  213. minWidth: 110,
  214. formatter: (_row) => {
  215. if (_row.level) {
  216. return this.assetLevel.filter(
  217. (item) => item.id == _row.level
  218. )[0].name;
  219. } else {
  220. return '';
  221. }
  222. }
  223. },
  224. {
  225. prop: 'networkStatus',
  226. label: '网络状态',
  227. showOverflowTooltip: true,
  228. minWidth: 110,
  229. formatter: (_row) => {
  230. if (_row.networkStatus) {
  231. return this.networkStatus.filter(
  232. (item) => item.code == _row.networkStatus
  233. )[0].label;
  234. } else {
  235. return '离线';
  236. }
  237. }
  238. },
  239. {
  240. prop: 'status',
  241. label: '状态',
  242. showOverflowTooltip: true,
  243. minWidth: 110,
  244. formatter: (_row) => {
  245. if (_row.status) {
  246. return this.businessStatus.filter(
  247. (item) => item.code == _row.status
  248. )[0].label;
  249. } else {
  250. return '空闲';
  251. }
  252. }
  253. },
  254. {
  255. prop: 'pathName',
  256. label: '位置',
  257. showOverflowTooltip: true,
  258. minWidth: 110,
  259. formatter: (_row) => {
  260. const positionDetail =
  261. _row.position &&
  262. _row.position.length != 0 &&
  263. _row.position[0].detailPosition
  264. ? _row.position[0].detailPosition
  265. : '-';
  266. return _row.deviceLocationName
  267. ? _row.deviceLocationName + '-' + positionDetail
  268. : '';
  269. }
  270. },
  271. {
  272. columnKey: 'action',
  273. slot: 'action',
  274. label: '操作',
  275. minWidth: 100,
  276. fixed: 'right'
  277. }
  278. ],
  279. checkRadioData: []
  280. };
  281. },
  282. computed: {
  283. clientEnvironmentId() {
  284. return this.$store.state.user.info.clientEnvironmentId;
  285. }
  286. },
  287. created() {
  288. this.requestDict('生命周期');
  289. this.getAssetLevelOptions();
  290. },
  291. methods: {
  292. allPrinting() {
  293. if (this.clientEnvironmentId == 2) {
  294. this.$refs.printSrRef.open(this.checkRadioData);
  295. } else if (this.clientEnvironmentId == 3) {
  296. this.$refs.printTgRef.open(this.checkRadioData);
  297. } else {
  298. this.$refs.printRef.open(this.checkRadioData);
  299. }
  300. },
  301. // 全选
  302. changeSelectAll(arr) {
  303. console.log(arr);
  304. if (arr.length != 0) {
  305. this.checkRadioData = arr;
  306. } else {
  307. this.checkRadioData = [];
  308. }
  309. },
  310. selectChange(selection, row) {
  311. if (selection.length != 0) {
  312. this.checkRadioData = selection;
  313. } else {
  314. this.checkRadioData = [];
  315. }
  316. },
  317. // 获取资产级别下拉
  318. async getAssetLevelOptions() {
  319. let { data } = await getByCode('asset_level');
  320. this.assetLevel =
  321. data.length > 0
  322. ? data.map((item) => {
  323. return {
  324. name: Object.keys(item)[0],
  325. id: item[Object.keys(item)[0]]
  326. };
  327. })
  328. : [];
  329. },
  330. // 跳转到详情页
  331. add() {
  332. this.$router.push({
  333. path: '/ledgerAssets/mould/edit'
  334. });
  335. },
  336. /* 表格数据源 */
  337. datasource({ page, limit, where, order }) {
  338. return getAssetList({
  339. ...where,
  340. ...order,
  341. pageNum: page,
  342. size: limit,
  343. categoryLevelId: this.categoryId,
  344. rootCategoryLevelId: this.rootId
  345. });
  346. },
  347. /* 刷新表格 */
  348. reload(where) {
  349. this.$refs.table.reload({ pageNum: 1, where: where });
  350. },
  351. // 跳转到详情页
  352. details({ id }) {
  353. this.$router.push({
  354. path: '/ledgerAssets/mould/detail',
  355. query: {
  356. id
  357. }
  358. });
  359. },
  360. // 跳转到编辑页
  361. goEdit({ id }) {
  362. console.log(id);
  363. this.$router.push({
  364. path: '/ledgerAssets/mould/edit',
  365. query: {
  366. id
  367. }
  368. });
  369. },
  370. // 导出
  371. btnExport() {
  372. let params = {
  373. ...this.$refs.searchRef.where,
  374. exportType: 3,
  375. categoryLevelId: this.categoryId,
  376. rootCategoryLevelId: this.rootId
  377. };
  378. axios({
  379. url: `${API_BASE_URL}/main/asset/page/export`,
  380. method: 'post',
  381. responseType: 'blob',
  382. headers: {
  383. Authorization: getToken()
  384. },
  385. data: params
  386. }).then((res) => {
  387. download(res.data, '模具台账导出数据');
  388. });
  389. // downloadAsset(params, '模具台账导出数据');
  390. }
  391. },
  392. watch: {
  393. // 监听类别id变化
  394. categoryId() {
  395. this.reload();
  396. }
  397. }
  398. };
  399. </script>
  400. <style lang="scss" scoped>
  401. .ele-btn-icon {
  402. margin-left: 20px;
  403. }
  404. </style>