You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

544 lines
18 KiB

3 years ago
  1. <template>
  2. <div class="mod-config">
  3. <el-row>
  4. <el-col :span="24">
  5. <el-button @click="getDataList()" type="primary">查询</el-button>
  6. <download-excel
  7. :fields="fields()"
  8. :data="exportData"
  9. type="xls"
  10. :name="exportName"
  11. :header="exportHeader"
  12. :footer="exportFooter"
  13. :defaultValue="exportDefaultValue"
  14. :fetch="createExportData"
  15. :before-generate="startDownload"
  16. :before-finish="finishDownload"
  17. worksheet="导出信息"
  18. class="el-button el-button--primary el-button--medium">
  19. 导出
  20. </download-excel>
  21. </el-col>
  22. </el-row>
  23. <el-row>
  24. <el-col :span="24">
  25. <el-form :inline="true" label-position="top">
  26. <el-form-item :label="'工具编码'">
  27. <el-input style="width: 100px" v-model="queryTool.toolId" ></el-input>
  28. </el-form-item>
  29. <el-form-item :label="'工具实例编码'">
  30. <el-input style="width: 100px" v-model="queryTool.toolInstanceId" ></el-input>
  31. </el-form-item>
  32. <el-form-item :label="'工具名称'">
  33. <el-input style="width: 100px" v-model="queryTool.toolDescription"></el-input>
  34. </el-form-item>
  35. <el-form-item>
  36. <span slot="label" @click="getBaseList(3,1)"><el-link>供应商编码</el-link> </span>
  37. <el-input style="width: 100px" v-model="queryTool.supplierId"></el-input>
  38. </el-form-item>
  39. <el-form-item :label="'接收日期'">
  40. <el-date-picker style="width: 120px" v-model="queryTool.startDate" value-format='yyyy-MM-dd 00:00:00' format = 'yyyy-MM-dd'
  41. ></el-date-picker> -
  42. <el-date-picker style="width: 120px" v-model="queryTool.endDate" value-format='yyyy-MM-dd 23:59:59' format = 'yyyy-MM-dd'
  43. ></el-date-picker>
  44. </el-form-item>
  45. <el-form-item :label="'使用比例'">
  46. <el-input type="number" style="width: 50px" v-model="queryTool.startProp"></el-input> -
  47. <el-input type="number" style="width: 50px" v-model="queryTool.endProp"></el-input>
  48. </el-form-item>
  49. </el-form>
  50. </el-col>
  51. </el-row>
  52. <el-row>
  53. <el-col :span="24">
  54. <el-table
  55. :height="height"
  56. :data="dataList"
  57. border
  58. v-loading="dataListLoading"
  59. highlight-current-row>
  60. <el-table-column
  61. fixed="left"
  62. header-align="center"
  63. align="left"
  64. width="100"
  65. :label="'操作'">
  66. <template slot-scope="scope">
  67. <el-link @click="printMethod(scope.row,'Y')">工具标签</el-link>
  68. <el-link @click="printMethod(scope.row,'N')">| 网版</el-link>
  69. </template>
  70. </el-table-column>
  71. <el-table-column
  72. v-for="(item,index) in columnList" :key="index"
  73. :sortable="item.columnSortable"
  74. :prop="item.columnProp"
  75. :header-align="item.headerAlign"
  76. :show-overflow-tooltip="item.showOverflowTooltip"
  77. :align="item.align"
  78. :fixed="item.fixed==''?false:item.fixed"
  79. :min-width="item.columnWidth"
  80. :label="item.columnLabel">
  81. <template slot-scope="scope">
  82. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  83. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. <el-pagination
  88. @size-change="sizeChangeHandle"
  89. @current-change="currentChangeHandle"
  90. :current-page="pageIndex"
  91. :page-sizes="[100, 200, 500]"
  92. :page-size="pageSize"
  93. :total="totalPage"
  94. layout="total, sizes, prev, pager, next, jumper">
  95. </el-pagination>
  96. </el-col>
  97. </el-row>
  98. <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  99. </div>
  100. </template>
  101. <script>
  102. import getLodop from '@/utils/LodopFuncs.js'
  103. import column from '../common/column'
  104. import Chooselist from '@/views/modules/common/Chooselist'
  105. import {getToolInfoList} from '@/api/knifemold/tool-info.js'
  106. import {printToolData} from '@/api/knifemold/receive.js'
  107. var functionId = '106001005'
  108. export default {
  109. components: {column, Chooselist},
  110. data () {
  111. return {
  112. buttons: {
  113. search: '查询',
  114. download: '导出'
  115. },
  116. queryButton: {
  117. functionId: functionId,
  118. table_id: '*',
  119. languageCode: this.$i18n.locale,
  120. objectType: 'button'
  121. },
  122. queryLabel: {
  123. functionId: functionId,
  124. table_id: '*',
  125. languageCode: this.$i18n.locale,
  126. objectType: 'label'
  127. },
  128. height: 0,
  129. // 组件显示控制
  130. visible: false,
  131. showDefault: this.$store.state.user.userDev,
  132. // 数据查询属性
  133. tagNo: '',
  134. dataListLoading: false,
  135. queryTool: {
  136. limit: 500,
  137. page: 1,
  138. supplierId: '',
  139. toolId: '',
  140. toolInstanceId: '',
  141. locationId: '',
  142. toolDescription: '',
  143. startDate: '',
  144. endDate: '',
  145. startProp: null,
  146. endProp: null
  147. },
  148. pageIndex: 1,
  149. pageSize: 100,
  150. totalPage: 0,
  151. // 数据集
  152. dataList: [],
  153. // ------------ 页面属性 ----------
  154. // 默认table 查询参数
  155. queryTable: {
  156. functionId: this.$route.meta.menuId,
  157. tableId: 'toolInfo',
  158. languageCode: this.$i18n.locale
  159. },
  160. // 用户table 查询参数
  161. queryTableUser: {
  162. userId: this.$store.state.user.name,
  163. functionId: this.$route.meta.menuId,
  164. tableId: 'toolInfo',
  165. status: true,
  166. languageCode: this.$i18n.locale
  167. },
  168. // 展示列集
  169. columnList: [
  170. {
  171. userId: this.$store.state.user.name,
  172. serialNumber: 'toolDetail1101ToolId',
  173. tableId: 'toolOIRecord',
  174. tableName: 'common',
  175. columnProp: 'toolId',
  176. headerAlign: 'center',
  177. align: 'left',
  178. columnLabel: '工具编码',
  179. columnHidden: false,
  180. columnImage: false,
  181. columnSortable: false,
  182. sortLv: 0,
  183. status: true,
  184. fixed: 'left',
  185. columnWidth: 140
  186. },
  187. {
  188. userId: this.$store.state.user.name,
  189. serialNumber: 'toolDetail1101ToolInstanceId',
  190. tableId: 'toolOIRecord',
  191. tableName: 'common',
  192. columnProp: 'toolInstanceId',
  193. headerAlign: 'center',
  194. align: 'left',
  195. columnLabel: '工具实例编码',
  196. columnHidden: false,
  197. columnImage: false,
  198. columnSortable: false,
  199. sortLv: 0,
  200. status: true,
  201. fixed: '',
  202. columnWidth: 140
  203. },
  204. {
  205. userId: this.$store.state.user.name,
  206. serialNumber: 'toolOIRecordtype',
  207. tableId: 'toolOIRecord',
  208. tableName: 'common',
  209. columnProp: 'toolDescription',
  210. headerAlign: 'center',
  211. align: 'left',
  212. columnLabel: '工具名称',
  213. columnHidden: false,
  214. columnImage: false,
  215. columnSortable: false,
  216. sortLv: 0,
  217. status: true,
  218. fixed: '',
  219. columnWidth: 200
  220. },
  221. {
  222. userId: this.$store.state.user.name,
  223. serialNumber: 'toolOIRecordCreateDate',
  224. tableId: 'toolOIRecord',
  225. tableName: 'common',
  226. columnProp: 'createDate',
  227. headerAlign: 'center',
  228. align: 'left',
  229. columnLabel: '接收日期',
  230. columnHidden: false,
  231. columnImage: false,
  232. columnSortable: false,
  233. sortLv: 0,
  234. status: true,
  235. fixed: '',
  236. columnWidth: 120
  237. },
  238. {
  239. userId: this.$store.state.user.name,
  240. serialNumber: 'toolOIRecordStatus',
  241. tableId: 'toolOIRecord',
  242. tableName: 'common',
  243. columnProp: 'status',
  244. headerAlign: 'center',
  245. align: 'left',
  246. columnLabel: '状态',
  247. columnHidden: false,
  248. columnImage: false,
  249. columnSortable: false,
  250. sortLv: 0,
  251. status: true,
  252. fixed: '',
  253. columnWidth: 100
  254. },
  255. {
  256. userId: this.$store.state.user.name,
  257. serialNumber: 'toolOIRecordCurrLocationId',
  258. tableId: 'toolOIRecord',
  259. tableName: 'common',
  260. columnProp: 'currLocationId',
  261. headerAlign: 'center',
  262. align: 'left',
  263. columnLabel: '库位编码',
  264. columnHidden: false,
  265. columnImage: false,
  266. columnSortable: false,
  267. sortLv: 0,
  268. status: true,
  269. fixed: '',
  270. columnWidth: 120
  271. },
  272. {
  273. userId: this.$store.state.user.name,
  274. serialNumber: 'toolOIRecordCurrLocationId',
  275. tableId: 'toolOIRecord',
  276. tableName: 'common',
  277. columnProp: 'locationName',
  278. headerAlign: 'center',
  279. align: 'left',
  280. columnLabel: '库位名称',
  281. columnHidden: false,
  282. columnImage: false,
  283. columnSortable: false,
  284. sortLv: 0,
  285. status: true,
  286. fixed: '',
  287. columnWidth: 160
  288. },
  289. {
  290. userId: this.$store.state.user.name,
  291. serialNumber: 'toolOIRecordActualuseQty',
  292. tableId: 'toolOIRecord',
  293. tableName: 'common',
  294. columnProp: 'actualuseQty',
  295. headerAlign: 'center',
  296. align: 'right',
  297. columnLabel: '已使用寿命',
  298. columnHidden: false,
  299. columnImage: false,
  300. columnSortable: false,
  301. sortLv: 0,
  302. status: true,
  303. fixed: '',
  304. columnWidth: 100
  305. },
  306. {
  307. userId: this.$store.state.user.name,
  308. serialNumber: 'toolOIRecordEstuseQty',
  309. tableId: 'toolOIRecord',
  310. tableName: 'common',
  311. columnProp: 'estuseQty',
  312. headerAlign: 'center',
  313. align: 'right',
  314. columnLabel: '预计使用寿命',
  315. columnHidden: false,
  316. columnImage: false,
  317. columnSortable: false,
  318. sortLv: 0,
  319. status: true,
  320. fixed: '',
  321. columnWidth: 100
  322. },
  323. {
  324. userId: this.$store.state.user.name,
  325. serialNumber: 'toolOIRecordProp',
  326. tableId: 'toolOIRecord',
  327. tableName: 'common',
  328. columnProp: 'prop',
  329. headerAlign: 'center',
  330. align: 'right',
  331. columnLabel: '使用比例',
  332. columnHidden: false,
  333. columnImage: false,
  334. columnSortable: false,
  335. sortLv: 0,
  336. status: true,
  337. fixed: '',
  338. columnWidth: 100
  339. }
  340. ],
  341. // 用户table 配置集合
  342. userColumnList: [],
  343. // ------------ 页面属性 end ----------
  344. // 导出 start
  345. exportData: [],
  346. exportName: this.$route.meta.title,
  347. exportHeader: [this.$route.meta.title],
  348. exportFooter: [],
  349. exportDefaultValue: ''
  350. }
  351. },
  352. activated () {
  353. },
  354. mounted () {
  355. this.$nextTick(() => {
  356. this.height = window.innerHeight - 220
  357. })
  358. },
  359. methods: {
  360. printMethod (row, printType) {
  361. let dto = {
  362. site: this.$store.state.user.site,
  363. toolInstanceId: row.toolInstanceId
  364. }
  365. printToolData(dto).then(({data}) => {
  366. if (data.code === 0) {
  367. let printDataList = []
  368. let printData = {
  369. SupplierName: data.data.SupplierName,
  370. createDate: data.data.createDate,
  371. createdBy: data.data.createdBy,
  372. estUseQty: data.data.estUseQty,
  373. locationId: data.data.locationId,
  374. phaseInDate: data.data.phaseInDate,
  375. site: data.data.site,
  376. spec: data.data.spec,
  377. status: data.data.status,
  378. supplierId: data.data.supplierId,
  379. toolDescription: data.data.toolDescription,
  380. toolId: data.data.toolId,
  381. toolInstanceId: row.toolInstanceId
  382. }
  383. printDataList.push(printData)
  384. if (printType === 'Y') {
  385. this.labelPrintGJ(printDataList)
  386. } else {
  387. this.labelPrintWB(printDataList)
  388. }
  389. }
  390. })
  391. },
  392. labelPrintWB (printDataList) {
  393. const LODOP = getLodop()
  394. if (LODOP) {
  395. // 循环调用打印机
  396. for (let i = 0; i < printDataList.length; i++) {
  397. let printData = printDataList[i]
  398. LODOP.NewPage()
  399. LODOP.SET_PRINT_PAGESIZE(0, 700, 180, '')
  400. LODOP.SET_PRINT_MODE('PRINT_NOCOLLATE', 1)
  401. LODOP.ADD_PRINT_RECT(2, 5, 250, 67, 0, 1)
  402. LODOP.ADD_PRINT_LINE(19, 5, 18, 255, 0, 1)
  403. LODOP.ADD_PRINT_LINE(36, 5, 35, 205, 0, 1)
  404. LODOP.ADD_PRINT_LINE(54, 5, 53, 205, 0, 1)
  405. LODOP.ADD_PRINT_LINE(2, 65, 69, 66, 0, 1)
  406. LODOP.ADD_PRINT_LINE(68, 205, 18, 206, 0, 1)
  407. LODOP.ADD_PRINT_BARCODE(21, 208, 90, 60, 'QRCode', printData.toolInstanceId)
  408. LODOP.ADD_PRINT_TEXT(5, 9, 60, 14, '工具名称')
  409. LODOP.ADD_PRINT_TEXT(21, 9, 60, 15, '工具编号')
  410. LODOP.ADD_PRINT_TEXT(38, 9, 60, 15, '实例编号')
  411. LODOP.ADD_PRINT_TEXT(55, 9, 60, 15, '经办人')
  412. LODOP.ADD_PRINT_TEXT(4, 70, 180, 14, printData.toolDescription)
  413. LODOP.SET_PRINT_STYLEA(0, 'Alignment', 2)
  414. LODOP.ADD_PRINT_TEXT(21, 71, 133, 14, printData.toolId)
  415. LODOP.ADD_PRINT_TEXT(39, 71, 133, 14, printData.toolInstanceId)
  416. LODOP.ADD_PRINT_TEXT(55, 71, 133, 14, printData.createdBy)
  417. }
  418. LODOP.PREVIEW()
  419. }
  420. },
  421. labelPrintGJ (printDataList) {
  422. const LODOP = getLodop()
  423. if (LODOP) {
  424. // 循环调用打印机
  425. for (let i = 0; i < printDataList.length; i++) {
  426. let printData = printDataList[i]
  427. LODOP.NewPage()
  428. LODOP.SET_PRINT_PAGESIZE(0, 700, 540, '')
  429. LODOP.ADD_PRINT_RECT(6, 5, 250, 190, 0, 1)
  430. LODOP.ADD_PRINT_LINE(24, 5, 23, 255, 0, 1)
  431. LODOP.ADD_PRINT_LINE(41, 5, 40, 255, 0, 1)
  432. LODOP.ADD_PRINT_LINE(58, 5, 57, 255, 0, 1)
  433. LODOP.ADD_PRINT_LINE(75, 5, 74, 255, 0, 1)
  434. LODOP.ADD_PRINT_LINE(92, 5, 91, 255, 0, 1)
  435. LODOP.ADD_PRINT_LINE(109, 5, 108, 255, 0, 1)
  436. LODOP.ADD_PRINT_LINE(126, 5, 125, 178, 0, 1)
  437. LODOP.ADD_PRINT_LINE(144, 5, 143, 178, 0, 1)
  438. LODOP.ADD_PRINT_LINE(162, 5, 161, 178, 0, 1)
  439. LODOP.ADD_PRINT_LINE(179, 5, 178, 255, 0, 1)
  440. LODOP.ADD_PRINT_LINE(23, 65, 195, 66, 0, 1)
  441. LODOP.ADD_PRINT_LINE(178, 177, 108, 178, 0, 1)
  442. LODOP.ADD_PRINT_BARCODE(110, 183, 110, 85, 'QRCode', printData.toolInstanceId)
  443. LODOP.ADD_PRINT_TEXT(9, 94, 100, 14, '工具标签')
  444. LODOP.SET_PRINT_STYLEA(0, 'Bold', 1)
  445. LODOP.ADD_PRINT_TEXT(26, 9, 60, 14, '工具名称')
  446. LODOP.ADD_PRINT_TEXT(43, 9, 60, 15, '规格型号')
  447. LODOP.ADD_PRINT_TEXT(60, 9, 60, 15, '工具编号')
  448. LODOP.ADD_PRINT_TEXT(77, 9, 60, 15, '实例编号')
  449. LODOP.ADD_PRINT_TEXT(94, 9, 60, 15, '厂商')
  450. LODOP.ADD_PRINT_TEXT(111, 9, 60, 15, '入库日期')
  451. LODOP.ADD_PRINT_TEXT(129, 9, 60, 15, '库位')
  452. LODOP.ADD_PRINT_TEXT(147, 9, 60, 15, '经办人')
  453. LODOP.ADD_PRINT_TEXT(181, 9, 60, 15, '检验签章')
  454. LODOP.ADD_PRINT_TEXT(25, 72, 180, 14, printData.toolDescription)
  455. LODOP.SET_PRINT_STYLEA(0, 'Alignment', 2)
  456. LODOP.ADD_PRINT_TEXT(42, 72, 180, 14, printData.spec) // 规格
  457. LODOP.ADD_PRINT_TEXT(60, 72, 180, 14, printData.toolId)
  458. LODOP.ADD_PRINT_TEXT(78, 71, 180, 14, printData.toolInstanceId)
  459. LODOP.ADD_PRINT_TEXT(94, 71, 180, 14, printData.SupplierName)
  460. LODOP.ADD_PRINT_TEXT(111, 71, 95, 14, this.dayjs(printData.createDate).format('YYYY-MM-DD'))
  461. LODOP.ADD_PRINT_TEXT(130, 71, 95, 14, printData.locationId)
  462. LODOP.ADD_PRINT_TEXT(148, 71, 95, 14, printData.createdBy)
  463. }
  464. LODOP.PREVIEW()
  465. }
  466. },
  467. // --------------- 业务 -------------------
  468. getDataList () {
  469. this.dataListLoading = true
  470. this.queryTool.limit = this.pageSize
  471. this.queryTool.page = this.pageIndex
  472. getToolInfoList(this.queryTool).then(({data}) => {
  473. if (data.code === 0) {
  474. this.dataList = data.data.list
  475. this.pageIndex = data.data.currPage
  476. this.pageSize = data.data.pageSize
  477. this.totalPage = data.data.totalCount
  478. }
  479. this.dataListLoading = false
  480. })
  481. },
  482. getBaseData (val) {
  483. if (this.tagNo === 3) {
  484. this.queryTool.supplierId = val.SupplierID
  485. }
  486. },
  487. // 获取基础数据列表
  488. getBaseList (val, number) {
  489. this.tagNo = val
  490. this.$nextTick(() => {
  491. let strVal = ''
  492. if (val === 3) {
  493. strVal = this.queryTool.supplierId
  494. }
  495. this.$refs.baseList.init(val, strVal)
  496. })
  497. },
  498. // --------- 分页 ----------
  499. // 每页数
  500. sizeChangeHandle (val) {
  501. this.pageSize = val
  502. this.pageIndex = 1
  503. this.getDataList()
  504. },
  505. // 当前页
  506. currentChangeHandle (val) {
  507. this.pageIndex = val
  508. this.getDataList()
  509. },
  510. // --------- 分页 end ----------
  511. // --------- 导出 ----------
  512. fields () {
  513. let json = "{"
  514. this.columnList.forEach((item, index) => {
  515. if (index == this.columnList.length - 1) {
  516. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  517. } else {
  518. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  519. }
  520. })
  521. json += "}"
  522. let s = eval("(" + json + ")")
  523. return s
  524. },
  525. createExportData () {
  526. // 点击导出按钮之后,开始导出数据之前的执行函数,返回值为需要下载的数据
  527. return this.dataList
  528. },
  529. startDownload () {
  530. },
  531. finishDownload () {
  532. }
  533. // --------- 导出 end ----------
  534. },
  535. created () {
  536. this.getTableUserColumn()
  537. }
  538. }
  539. </script>
  540. <style>
  541. </style>