index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <template>
  2. <el-card class="box-card">
  3. <byTable
  4. :source="sourceList.data"
  5. :pagination="sourceList.pagination"
  6. :config="config"
  7. :loading="loading"
  8. :searchConfig="searchConfig"
  9. highlight-current-row
  10. :table-events="{
  11. select: selectRow,
  12. 'select-all': selectRow,
  13. }"
  14. :action-list="[
  15. {
  16. text: '打印生产面单',
  17. action: () => clickSelectPrint(),
  18. },
  19. ]"
  20. @get-list="getList"
  21. @clickReset="clickReset"
  22. @changeRadioGroup="changeRadioGroup">
  23. <template #code="{ item }">
  24. <div>
  25. <a style="color: #409eff; cursor: pointer; word-break: break-all" @click="clickCode(item)">{{ item.code }}</a>
  26. </div>
  27. </template>
  28. <template #address="{ item }">
  29. <div>{{ item.province }}, {{ item.city }}, {{ item.county }}, {{ item.detailedAddress }}</div>
  30. </template>
  31. </byTable>
  32. <div style="display: none">
  33. <div style="width: 250px" id="printMe">
  34. <div v-for="(item, index) in QRcodeList" :key="index">
  35. <div style="height: 442px; padding-top: 2px; overflow: hidden; position: relative">
  36. <div style="border-bottom: 1px solid #000; display: flex; align-items: center; justify-content: center">
  37. <CycleBarcode :value="item.orderWlnCode || item.orderCode" :index="index" style="max-width: 100%"></CycleBarcode>
  38. </div>
  39. <div style="display: flex; align-items: center; justify-content: center">
  40. <div style="width: 150px; height: 150px; margin-top: 8px" :id="'print' + index" :ref="'print' + index">
  41. <img src="" alt="" style="vertical-align: middle; height: 100%; width: 100%" />
  42. </div>
  43. </div>
  44. <div style="text-align: center; font-size: 18px; font-weight: 700; padding: 4px 0; border-bottom: 1px solid #000">{{ item.completeTime }}</div>
  45. <div style="word-break: break-all; padding: 2px">SKU品号:{{ item.skuSpecCode }}</div>
  46. <div style="word-break: break-all; padding: 2px">SKU品名:{{ item.skuSpecName }}</div>
  47. <div style="word-break: break-all; padding: 2px">BOM品号:{{ item.bomSpecCode }}</div>
  48. <div style="word-break: break-all; padding: 2px">BOM品名:{{ item.bomSpecName }}</div>
  49. <div v-if="item.orderWlnCode" class="one">
  50. <div class="two">
  51. <div class="three">万里牛</div>
  52. </div>
  53. </div>
  54. </div>
  55. <div style="page-break-after: always"></div>
  56. </div>
  57. </div>
  58. <el-button type="primary" style="display: none" v-print="printObj" id="printBtnMini"></el-button>
  59. </div>
  60. </el-card>
  61. </template>
  62. <script setup>
  63. import byTable from "/src/components/byTable/index";
  64. import { getNearDays } from "/src/utils/util";
  65. import QRCode from "qrcodejs2-fix";
  66. import { ElMessage } from "element-plus";
  67. import CycleBarcode from "/src/components/CycleBarcode";
  68. const { proxy } = getCurrentInstance();
  69. const sourceList = ref({
  70. data: [],
  71. pagination: {
  72. total: 0,
  73. pageNum: 1,
  74. pageSize: 10,
  75. orderCode: "",
  76. orderWlnCode: "",
  77. skuSpecCode: "",
  78. skuSpecName: "",
  79. bomSpecCode: "",
  80. bomSpecName: "",
  81. productionWorkOrderCode: "",
  82. beginTime: "",
  83. endTime: "",
  84. type: 3,
  85. },
  86. });
  87. const loading = ref(false);
  88. const searchConfig = computed(() => {
  89. return [
  90. {
  91. type: "input",
  92. prop: "orderCode",
  93. label: "订单号",
  94. },
  95. {
  96. type: "input",
  97. prop: "orderWlnCode",
  98. label: "E10单号",
  99. },
  100. {
  101. type: "input",
  102. prop: "skuSpecCode",
  103. label: "SKU品号",
  104. },
  105. {
  106. type: "input",
  107. prop: "skuSpecName",
  108. label: "SKU品名",
  109. },
  110. {
  111. type: "input",
  112. prop: "bomSpecCode",
  113. label: "BOM品号",
  114. },
  115. {
  116. type: "input",
  117. prop: "bomSpecName",
  118. label: "BOM品名",
  119. },
  120. {
  121. type: "input",
  122. prop: "productionWorkOrderCode",
  123. label: "工单号",
  124. },
  125. {
  126. type: "radio-group",
  127. prop: "type",
  128. label: "交期",
  129. data: [
  130. {
  131. dictKey: 1,
  132. dictValue: "近3天",
  133. },
  134. {
  135. dictKey: 3,
  136. dictValue: "近7天",
  137. },
  138. {
  139. dictKey: 15,
  140. dictValue: "近31天",
  141. },
  142. ],
  143. },
  144. {
  145. type: "date",
  146. propList: ["beginTime", "endTime"],
  147. label: "日期",
  148. },
  149. ];
  150. });
  151. const config = computed(() => {
  152. return [
  153. {
  154. type: "selection",
  155. attrs: {
  156. checkAtt: "isCheck",
  157. },
  158. },
  159. {
  160. attrs: {
  161. label: "订单号",
  162. prop: "orderCode",
  163. width: 150,
  164. },
  165. },
  166. {
  167. attrs: {
  168. label: "工单号",
  169. prop: "code",
  170. width: 190,
  171. },
  172. },
  173. {
  174. attrs: {
  175. label: "E10单号",
  176. prop: "orderWlnCode",
  177. width: 150,
  178. },
  179. },
  180. {
  181. attrs: {
  182. label: "SKU品号",
  183. prop: "skuSpecCode",
  184. width: 140,
  185. },
  186. },
  187. {
  188. attrs: {
  189. label: "SKU品名",
  190. prop: "skuSpecName",
  191. "min-width": 220,
  192. },
  193. },
  194. {
  195. attrs: {
  196. label: "BOM品号",
  197. prop: "bomSpecCode",
  198. width: 130,
  199. },
  200. },
  201. {
  202. attrs: {
  203. label: "BOM品名",
  204. prop: "bomSpecName",
  205. "min-width": 280,
  206. },
  207. },
  208. {
  209. attrs: {
  210. label: "生产状态",
  211. prop: "status",
  212. width: 80,
  213. },
  214. render(val) {
  215. if (val == 0) {
  216. return "待投产";
  217. }
  218. },
  219. },
  220. {
  221. attrs: {
  222. label: "完成时间",
  223. prop: "completeTime",
  224. width: 160,
  225. align: "center",
  226. fixed: "right",
  227. },
  228. },
  229. {
  230. attrs: {
  231. label: "操作",
  232. width: 120,
  233. align: "center",
  234. fixed: "right",
  235. },
  236. renderHTML(row) {
  237. return [
  238. {
  239. attrs: {
  240. label: "打印生产面单",
  241. type: "primary",
  242. text: true,
  243. },
  244. el: "button",
  245. click() {
  246. clickPrint([row]);
  247. },
  248. },
  249. ];
  250. },
  251. },
  252. ];
  253. });
  254. const getList = async (req, status) => {
  255. if (status) {
  256. sourceList.value.pagination = {
  257. pageNum: sourceList.value.pagination.pageNum,
  258. pageSize: sourceList.value.pagination.pageSize,
  259. type: 3,
  260. beginTime: getNearDays(3).beginTime,
  261. endTime: getNearDays(3).endTime,
  262. };
  263. } else {
  264. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  265. }
  266. loading.value = true;
  267. proxy.post("/productionWorkOrder/page", sourceList.value.pagination).then((res) => {
  268. if (res.rows && res.rows.length > 0) {
  269. sourceList.value.data = res.rows.map((item) => {
  270. return {
  271. ...item,
  272. isCheck: true,
  273. };
  274. });
  275. } else {
  276. sourceList.value.data = [];
  277. }
  278. sourceList.value.pagination.total = res.total;
  279. setTimeout(() => {
  280. loading.value = false;
  281. }, 200);
  282. });
  283. };
  284. getList({ beginTime: getNearDays(3).beginTime, endTime: getNearDays(3).endTime });
  285. const clickReset = () => {
  286. getList("", true);
  287. };
  288. const changeRadioGroup = () => {
  289. getList({ beginTime: getNearDays(sourceList.value.pagination.type).beginTime, endTime: getNearDays(sourceList.value.pagination.type).endTime });
  290. };
  291. const clickCode = (row) => {
  292. proxy.$router.replace({
  293. path: "/addOrder",
  294. query: {
  295. detailId: row.id,
  296. text: "订单详情",
  297. random: proxy.random(),
  298. orderInquiry: true,
  299. },
  300. });
  301. };
  302. const printObj = ref({
  303. id: "printMe",
  304. popTitle: "",
  305. extraCss: "https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.1/animate.compat.css, https://cdn.bootcdn.net/ajax/libs/hover.css/2.3.1/css/hover-min.css",
  306. extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
  307. });
  308. const selectData = ref([]);
  309. const selectRow = (data) => {
  310. selectData.value = data;
  311. };
  312. const QRcodeList = ref([]);
  313. const clickPrint = (list) => {
  314. QRcodeList.value = list;
  315. nextTick(() => {
  316. for (let i = 0; i < QRcodeList.value.length; i++) {
  317. proxy.$refs["print" + i][0].innerHTML = ""; //清除二维码方法一
  318. let text = QRcodeList.value[i].skuSpecCode;
  319. new QRCode(proxy.$refs["print" + i][0], {
  320. text: text, //页面地址 ,如果页面需要参数传递请注意哈希模式#
  321. width: 150,
  322. height: 150,
  323. colorDark: "#000000",
  324. colorLight: "#ffffff",
  325. correctLevel: QRCode.CorrectLevel.H,
  326. });
  327. }
  328. nextTick(() => {
  329. const btn = document.getElementById("printBtnMini");
  330. btn.click();
  331. });
  332. });
  333. };
  334. const clickSelectPrint = () => {
  335. if (selectData.value && selectData.value.length > 0) {
  336. clickPrint(selectData.value);
  337. } else {
  338. return ElMessage("请选择需要打印的工单");
  339. }
  340. };
  341. </script>
  342. <style lang="scss" scoped>
  343. :deep(.el-dialog) {
  344. margin-top: 10px !important;
  345. margin-bottom: 10px !important;
  346. }
  347. .one {
  348. position: absolute;
  349. right: 10px;
  350. top: 320px;
  351. width: 70px;
  352. height: 70px;
  353. z-index: 99;
  354. line-height: 80px;
  355. text-align: center;
  356. border-radius: 50%;
  357. border: 1px solid #000;
  358. .two {
  359. position: absolute;
  360. top: 50%;
  361. left: 50%;
  362. transform: translate(-50%, -50%);
  363. width: 60px;
  364. height: 60px;
  365. line-height: 60px;
  366. text-align: center;
  367. border-radius: 50%;
  368. border: 1px dashed #000;
  369. .three {
  370. rotate: -45deg;
  371. font-size: 14px;
  372. }
  373. }
  374. }
  375. </style>