qrCodeManagement.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <div class="qrCodeManagement">
  3. <di class="qrCodeManagement-header">
  4. <div class="header-filter">
  5. <div>项目号:</div>
  6. <el-input v-model="filterValForm.projectId" placeholder="请输入" size="small" style="width: 150px;"></el-input>
  7. </div>
  8. <div class="header-filter">
  9. <div>项目名:</div>
  10. <el-input v-model="filterValForm.projectName" placeholder="请输入" size="small" style="width: 150px;"></el-input>
  11. </div>
  12. <div class="header-filter">
  13. <div>生产工单号:</div>
  14. <el-input v-model="filterValForm.orderId" placeholder="请输入" size="small" style="width: 150px;"></el-input>
  15. </div>
  16. <div class="header-filter">
  17. <div>行号:</div>
  18. <el-input v-model="filterValForm.line" placeholder="请输入" size="small" style="width: 150px;"></el-input>
  19. </div>
  20. <div class="header-filter">
  21. <div>生产工单日期:</div>
  22. <el-date-picker v-model="filterValForm.relsDate" type="date" placeholder="选择日期" size="small"
  23. style="width: 150px;" value-format="YYYY-MM-dd">
  24. </el-date-picker>
  25. </div>
  26. </di>
  27. <div class="qrCodeManagement-con">
  28. <el-table :data="tableData" style="width: 100%" height="58vh" border @selection-change="handleSelectionChange" :loading="tableLoading">
  29. <el-table-column type="selection" width="55" />
  30. <el-table-column prop="projectId" label="项目号" />
  31. <el-table-column prop="projectName" label="项目名" />
  32. <el-table-column prop="orderId" label="生产工单号" />
  33. <el-table-column prop="line" label="行号" />
  34. </el-table>
  35. </div>
  36. <div class="qrCodeManagement-bon">
  37. <el-button type="primary" size="small" :disabled="!multipleSelection.length" @click="exportQrCode()"
  38. :loading="exportQrCodeLoading">导出二维码</el-button>
  39. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageIndex"
  40. :page-sizes="[100, 200, 300, 400, 500]" :page-size="pageSize" layout="total, prev, pager, next, sizes, jumper"
  41. :total="total">
  42. </el-pagination>
  43. </div>
  44. </div>
  45. </template>
  46. <script>
  47. export default {
  48. components: {},
  49. data() {
  50. return {
  51. user: JSON.parse(sessionStorage.getItem("user")),
  52. permissions: JSON.parse(sessionStorage.getItem("permissions")),
  53. tableData: [],
  54. multipleSelection: [],
  55. filterValForm: {
  56. orderId: '',
  57. projectId: '',
  58. projectName: '',
  59. line: '',
  60. relsDate: ''
  61. },
  62. pageIndex: 1,
  63. pageSize: 100,
  64. total: 0,
  65. exportQrCodeLoading: false,
  66. tableLoading: false,
  67. debounceTimer: null,
  68. };
  69. },
  70. watch: {
  71. filterValForm: {
  72. handler() {
  73. this.debounceGeTableData();
  74. },
  75. deep: true
  76. }
  77. },
  78. mounted() { },
  79. methods: {
  80. // 重置数据并加载
  81. resetData() {
  82. this.filterValForm = {
  83. orderId: '',
  84. projectId: '',
  85. projectName: '',
  86. line: '',
  87. relsDate: ''
  88. }
  89. this.pageIndex = 1
  90. this.pageSize = 100
  91. this.debounceGeTableData()
  92. },
  93. exportQrCode() {
  94. this.exportQrCodeLoading = true
  95. this.postData('/qrCode/generateQRCodeByErpIds', {
  96. erpIds: this.multipleSelection.map(item => item.id).join(',')
  97. }).then(res => {
  98. console.log('res', res)
  99. this.$message({
  100. message: '导出成功,下载中...',
  101. type: 'success'
  102. });
  103. var filePath = res.data;
  104. const a = document.createElement('a'); // 创建a标签
  105. a.setAttribute('download', '二维码' + '.zip');// download属性
  106. a.setAttribute('href', filePath);// href链接
  107. a.click(); //自执行点击事件
  108. a.remove();
  109. }).finally(() => {
  110. this.exportQrCodeLoading = false
  111. })
  112. },
  113. // 赛选条件改动执行
  114. debounceGeTableData() {
  115. clearTimeout(this.debounceTimer);
  116. this.debounceTimer = setTimeout(() => {
  117. this.geTableData();
  118. }, 500);
  119. },
  120. handleSelectionChange(val) {
  121. this.multipleSelection = val
  122. },
  123. handleSizeChange(val) {
  124. this.pageIndex = 1
  125. this.pageSize = val
  126. this.geTableData()
  127. },
  128. handleCurrentChange(val) {
  129. this.pageIndex = val
  130. this.geTableData()
  131. },
  132. geTableData() {
  133. const filteredParams = {};
  134. console.log(this.filterValForm, '<==== this.filterValForm')
  135. for (const key in this.filterValForm) {
  136. const val = this.filterValForm[key];
  137. if (val !== '' && val !== null && val !== undefined) {
  138. filteredParams[key] = val;
  139. }
  140. }
  141. this.tableLoading = true
  142. this.postData('/erpOrderInfo/getInfoPage', {
  143. pageIndex: this.pageIndex,
  144. pageSize: this.pageSize,
  145. ...filteredParams
  146. }).then(res => {
  147. console.log('res', res)
  148. console.log(res.data.data, '<======= 数据')
  149. this.tableData = res.data.data || []
  150. this.total = res.data.total || 0
  151. }).finally(() => {
  152. this.tableLoading = false
  153. })
  154. },
  155. async postData(urls, param) {
  156. return new Promise((resolve, reject) => {
  157. this.http.post(urls, { ...param },
  158. res => {
  159. if (res.code == 'ok') {
  160. resolve(res)
  161. } else {
  162. this.$message({
  163. message: res.msg,
  164. type: 'error'
  165. })
  166. reject(res)
  167. }
  168. resolve(res)
  169. },
  170. error => {
  171. this.$message({
  172. message: error,
  173. type: "error"
  174. });
  175. reject(error)
  176. }
  177. )
  178. });
  179. },
  180. },
  181. };
  182. </script>
  183. <style lang="scss" scoped>
  184. .qrCodeManagement {
  185. width: 100%;
  186. height: 70vh;
  187. .qrCodeManagement-header {
  188. display: flex;
  189. align-items: center;
  190. height: 8%;
  191. .header-filter {
  192. display: flex;
  193. align-items: center;
  194. margin-left: 14px;
  195. }
  196. }
  197. .qrCodeManagement-con {
  198. height: 84%;
  199. }
  200. .qrCodeManagement-bon {
  201. display: flex;
  202. align-items: center;
  203. justify-content: space-between;
  204. height: 8%;
  205. }
  206. }
  207. </style>