index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <template>
  2. <div class="pageIndexClass">
  3. <div>
  4. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" highlight-current-row
  5. :selectConfig="selectConfig" :action-list="[
  6. ]" @get-list="getList">
  7. <template #aa="{ item }">
  8. <div style="width:100%">
  9. <el-progress type="circle" :percentage="Number(item.completionRate)" width="60"
  10. :status="Number(item.completionRate) == 100 ? 'success' : ''" />
  11. </div>
  12. </template>
  13. <template v-for="(slotItem, index) in processesData" v-slot:[slotItem.id]="{ item }" :key="slotItem.id">
  14. <div style="width:100%">
  15. aaa
  16. </div>
  17. </template>
  18. </byTable>
  19. </div>
  20. <el-dialog :title="'打印二维码'" v-model="dialogVisible" width="350px" destroy-on-close>
  21. <div>
  22. <div id="pdfDom" style="width:100%">
  23. <div style="font-size:20px;text-align:center">
  24. {{printData.name}}
  25. </div>
  26. <div style="border-top: 1px solid #000;border-bottom: 1px solid #000; padding: 10px 0; margin:10px auto;text-align:center">
  27. <div :ref="printData.id" style="width:200px;margin-left:55px">
  28. {{printData.scanValue}}
  29. </div>
  30. <div style="font-size:20px;text-align:center;font-weight:700;margin-top:10px">
  31. {{printData.createTime}}
  32. </div>
  33. <!-- 换页 -->
  34. <!-- <div style="page-break-after: always"></div> -->
  35. </div>
  36. <div style="margin-left:10px;display:flex;flex-direction:column;justify-content:space-around">
  37. <div style="font-size:14px;margin-top:8px"> 产品编码:{{printData.productName}}</div>
  38. <div style="font-size:14px;margin-top:8px">
  39. 产品名称:{{printData.productSpec}}
  40. </div>
  41. <div style="font-size:14px;margin-top:8px">
  42. 原材料编码:{{printData.productSpec}}
  43. </div>
  44. <div style="font-size:14px;margin-top:8px">
  45. 原材料名称:{{printData.productSpec}}
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. <template #footer>
  51. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  52. <el-button type="primary" v-print="printObj" size="large">打 印</el-button>
  53. </template>
  54. </el-dialog>
  55. </div>
  56. </template>
  57. <script setup>
  58. import byTable from "@/components/byTable/index";
  59. import byForm from "@/components/byForm/index";
  60. import QRCode from "qrcodejs2-fix";
  61. const { proxy } = getCurrentInstance();
  62. const loading = ref(false);
  63. const submitLoading = ref(false);
  64. const sourceList = ref({
  65. data: [],
  66. pagination: {
  67. total: 3,
  68. pageNum: 1,
  69. pageSize: 10,
  70. keyword: "",
  71. },
  72. });
  73. const treeData = ref([]);
  74. const dialogVisible = ref(false);
  75. const modalType = ref("add");
  76. const statusData = ref([
  77. {
  78. label: "未开始",
  79. value: "0",
  80. },
  81. {
  82. label: "进行中",
  83. value: "1",
  84. },
  85. {
  86. label: "已完成",
  87. value: "2",
  88. },
  89. ]);
  90. const selectConfig = computed(() => [
  91. {
  92. label: "生产状态",
  93. prop: "status",
  94. data: statusData.value,
  95. },
  96. {
  97. type: "time",
  98. label: "交期",
  99. placeholder: "开始日期",
  100. prop: "time",
  101. placeholderOne: "结束日期",
  102. propOne: "time1",
  103. // data: status.value,
  104. },
  105. {
  106. type: "time",
  107. label: "下单日期",
  108. placeholder: "开始日期",
  109. prop: "time",
  110. placeholderOne: "结束日期",
  111. propOne: "time1",
  112. // data: status.value,
  113. },
  114. ]);
  115. const config = ref([
  116. {
  117. attrs: {
  118. label: "订单号",
  119. prop: "code",
  120. },
  121. },
  122. {
  123. attrs: {
  124. label: "设计图",
  125. prop: "code",
  126. },
  127. },
  128. {
  129. attrs: {
  130. label: "产品图片",
  131. prop: "code",
  132. },
  133. },
  134. {
  135. attrs: {
  136. label: "产品编码",
  137. prop: "name",
  138. },
  139. },
  140. {
  141. attrs: {
  142. label: "产品名称",
  143. prop: "name",
  144. },
  145. },
  146. {
  147. attrs: {
  148. label: "生产件数",
  149. prop: "deptName",
  150. },
  151. },
  152. {
  153. attrs: {
  154. label: "生产状态",
  155. prop: "deptName",
  156. },
  157. render(val) {
  158. return proxy.dictValueLabel(val, statusData.value);
  159. },
  160. },
  161. {
  162. attrs: {
  163. label: "下单时间",
  164. prop: "deptName",
  165. },
  166. },
  167. {
  168. attrs: {
  169. label: "交期",
  170. prop: "deptName",
  171. },
  172. },
  173. {
  174. attrs: {
  175. label: "投产时间",
  176. prop: "deptName",
  177. },
  178. },
  179. {
  180. attrs: {
  181. label: "完成时间",
  182. prop: "deptName",
  183. },
  184. },
  185. {
  186. attrs: {
  187. label: "生产用时",
  188. prop: "deptName",
  189. },
  190. },
  191. ]);
  192. const formData = reactive({
  193. data: {},
  194. });
  195. const formOption = reactive({
  196. inline: true,
  197. labelWidth: 100,
  198. itemWidth: 100,
  199. });
  200. const formDom = ref(null);
  201. const formConfig = computed(() => {
  202. return [
  203. {
  204. type: "input",
  205. prop: "code",
  206. label: "店铺编号",
  207. itemWidth: 100,
  208. disabled: false,
  209. },
  210. {
  211. type: "input",
  212. prop: "name",
  213. label: "店铺名称",
  214. itemWidth: 100,
  215. disabled: false,
  216. },
  217. {
  218. type: "treeSelect",
  219. prop: "deptId",
  220. label: "负责部门",
  221. data: treeData.value,
  222. propsTreeLabel: "deptName",
  223. propsTreeValue: "deptId",
  224. itemWidth: 100,
  225. disabled: false,
  226. },
  227. ];
  228. });
  229. const rules = ref({
  230. deptId: [{ required: true, message: "请选择负责部门", trigger: "change" }],
  231. name: [{ required: true, message: "请输入店铺名称", trigger: "blur" }],
  232. code: [{ required: true, message: "请输入店铺编号", trigger: "blur" }],
  233. });
  234. const getDeptData = () => {
  235. proxy
  236. .get("/tenantDept/list", {
  237. pageNum: 1,
  238. pageSize: 9999,
  239. keyword: "",
  240. tenantId: proxy.useUserStore().user.tenantId,
  241. })
  242. .then((res) => {
  243. treeData.value = proxy.handleTree(res.data, "deptId");
  244. });
  245. };
  246. getDeptData();
  247. const getList = async (req) => {
  248. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  249. loading.value = true;
  250. proxy.post("/shopInfo/page", sourceList.value.pagination).then((res) => {
  251. sourceList.value.data = res.rows;
  252. sourceList.value.pagination.total = res.total;
  253. setTimeout(() => {
  254. loading.value = false;
  255. }, 200);
  256. });
  257. };
  258. const openModal = () => {
  259. dialogVisible.value = true;
  260. modalType.value = "add";
  261. formData.data = {
  262. definition: "2",
  263. fileList: [],
  264. };
  265. if (currencyData.value && currencyData.value.length > 0) {
  266. formData.data.currency = currencyData.value[0].dictKey;
  267. formData.data.costCurrency = currencyData.value[0].dictKey;
  268. }
  269. };
  270. const submitForm = () => {
  271. formDom.value.handleSubmit((valid) => {
  272. submitLoading.value = true;
  273. proxy.post("/shopInfo/" + modalType.value, formData.data).then(
  274. (res) => {
  275. proxy.msgTip("操作成功", 1);
  276. dialogVisible.value = false;
  277. submitLoading.value = false;
  278. getList();
  279. },
  280. (err) => {
  281. submitLoading.value = false;
  282. }
  283. );
  284. });
  285. };
  286. const getDtl = (row) => {
  287. modalType.value = "edit";
  288. proxy.post("/shopInfo/detail", { id: row.id }).then((res) => {
  289. formData.data = res;
  290. dialogVisible.value = true;
  291. });
  292. };
  293. const processesData = ref([]);
  294. const getProcesses = () => {
  295. proxy
  296. .post("/productionProcesses/page", { pageNum: 1, pageSize: 9999 })
  297. .then((res) => {
  298. for (let i = 0; i < res.rows.length; i++) {
  299. const ele = res.rows[i];
  300. let attrs = {
  301. label: `[ ${ele.name} ]`,
  302. slot: ele.id,
  303. isNeedHeaderSlot: false,
  304. width: 90,
  305. fixed: "right",
  306. };
  307. config.value.push({
  308. attrs,
  309. });
  310. }
  311. config.value.push({
  312. attrs: {
  313. label: "操作",
  314. width: "100",
  315. align: "center",
  316. fixed: "right",
  317. },
  318. renderHTML(row) {
  319. return [
  320. {
  321. attrs: {
  322. label: "打印二维码",
  323. type: "primary",
  324. text: true,
  325. },
  326. el: "button",
  327. click() {
  328. printQrCode(row);
  329. },
  330. },
  331. ];
  332. },
  333. });
  334. processesData.value = res.rows;
  335. });
  336. };
  337. getProcesses();
  338. getList();
  339. const printData = ref({});
  340. const printQrCode = (row) => {
  341. printData.value = row;
  342. dialogVisible.value = true;
  343. nextTick(() => {
  344. proxy.$refs[row.id].innerHTML = ""; //清除二维码方法一
  345. new QRCode(proxy.$refs[row.id], {
  346. text: row.id,
  347. width: 200,
  348. height: 200,
  349. colorDark: "#000000",
  350. colorLight: "#ffffff",
  351. correctLevel: QRCode.CorrectLevel.H,
  352. });
  353. });
  354. };
  355. const printObj = ref({
  356. id: "pdfDom",
  357. popTitle: "",
  358. extraCss:
  359. "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",
  360. extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
  361. });
  362. </script>
  363. <style lang="scss" scoped>
  364. ::v-deep(.el-progress__text) {
  365. font-size: 14px !important;
  366. }
  367. .content {
  368. padding: 20px;
  369. }
  370. </style>