index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <div class="pageIndexClass" style="font-size:12px !important">
  3. <div>
  4. <byTable :source="sourceList.data" :tableBorder="true" :pagination="sourceList.pagination" :config="config" :loading="loading"
  5. highlight-current-row :selectConfig="selectConfig" :hidePagination="true" :action-list="[
  6. ]" @get-list="getList">
  7. <template #product="{ item }">
  8. <div style="width:100%;padding:0 6px">
  9. <el-popover placement="bottom-start" title="" :width="300" trigger="hover">
  10. <div default>
  11. {{item.productName}}
  12. </div>
  13. <template #reference>
  14. <div style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;cursor:pointer">
  15. {{item.productName}}
  16. </div>
  17. </template>
  18. </el-popover>
  19. </div>
  20. </template>
  21. <template #isOverdue="{item}">
  22. <div style="width: 100%">
  23. <span class="red" v-if="item.isOverdue=='1'"> 逾期 </span>
  24. </div>
  25. </template>
  26. <template #date="{ item }">
  27. <div style="width:100%; ">
  28. <div>
  29. {{item.produceTime}} ~ {{item.deliveryPeriod}}
  30. </div>
  31. </div>
  32. </template>
  33. <template v-for="(row) in allDay" v-slot:[row.key]="{ index }" :key="row.key">
  34. <div style="width:100%">
  35. <div style="height:12px" class="is-bk"
  36. :class="{'left-class':index>=0? isAddLeftClass(row,index):false,'right-class':index>=0? isAddRightClass(row,index):false,'all-class':index>=0? (isAddLeftClass(row,index)&&isAddRightClass(row,index)):false,'red-class':index>=0?isAddRedClass(index):false}"
  37. v-if="index>=0 &&sourceList.data && sourceList.data.length>0 && isAddClass(row.day,index)"></div>
  38. </div>
  39. </template>
  40. </byTable>
  41. </div>
  42. <el-dialog :title="'打印二维码'" v-model="dialogVisible" width="350px" destroy-on-close>
  43. <div>
  44. <div id="pdfDom" style="width:100%">
  45. <div style="font-size:20px;text-align:center">
  46. {{printData.name}}
  47. </div>
  48. <div style="border-top: 1px solid #000;border-bottom: 1px solid #000; padding: 10px 0; margin:10px auto;text-align:center">
  49. <div :ref="printData.id" style="width:200px;margin-left:55px">
  50. {{printData.scanValue}}
  51. </div>
  52. <div style="font-size:20px;text-align:center;font-weight:700;margin-top:10px">
  53. {{printData.produceTime}}
  54. </div>
  55. <!-- 换页 -->
  56. <!-- <div style="page-break-after: always"></div> -->
  57. </div>
  58. <div style="margin-left:10px;display:flex;flex-direction:column;justify-content:space-around">
  59. <div style="font-size:14px;margin-top:8px"> 产品编码:{{printData.productName}}</div>
  60. <div style="font-size:14px;margin-top:8px">
  61. 产品名称:{{printData.productSpec}}
  62. </div>
  63. <div style="font-size:14px;margin-top:8px">
  64. 原材料编码:{{printData.productSpec}}
  65. </div>
  66. <div style="font-size:14px;margin-top:8px">
  67. 原材料名称:{{printData.productSpec}}
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. <template #footer>
  73. <el-button @click="dialogVisible = false" size="defualt">取 消</el-button>
  74. <el-button type="primary" v-print="printObj" size="defualt">打 印</el-button>
  75. </template>
  76. </el-dialog>
  77. <el-dialog :title="'投产'" v-model="productionDialog" width="500px" destroy-on-close>
  78. <byForm :formConfig="productionFormConfig" :formOption="formOption" v-model="formData.data" :rules="productionRules" ref="productionFormDom"
  79. v-loading="formLoading">
  80. </byForm>
  81. <template #footer>
  82. <el-button @click="productionDialog =false" size="default" v-debounce>取 消</el-button>
  83. <el-button @click="submitProduction" type="primary" size="default" v-debounce>提 交</el-button>
  84. </template>
  85. </el-dialog>
  86. </div>
  87. </template>
  88. <script setup>
  89. import byTable from "@/components/byTable/index";
  90. import byForm from "@/components/byForm/index";
  91. import QRCode from "qrcodejs2-fix";
  92. import { getDateAllDay } from "@/utils/date.js";
  93. import moment from "moment";
  94. import { watch } from "vue";
  95. const { proxy } = getCurrentInstance();
  96. const companyData = ref([]);
  97. const loading = ref(false);
  98. const submitLoading = ref(false);
  99. let str = moment().format("yyyy-MM");
  100. const sourceList = ref({
  101. data: [],
  102. pagination: {
  103. total: 3,
  104. pageNum: 1,
  105. pageSize: 10,
  106. keyword: "",
  107. produceStatus: "",
  108. beginDate: str,
  109. endDeliveryPeriod: "",
  110. beginTime: "",
  111. endTime: "",
  112. isOverdue: "",
  113. },
  114. });
  115. const treeData = ref([]);
  116. const dialogVisible = ref(false);
  117. const modalType = ref("add");
  118. const allDay = ref([]);
  119. const changDay = (val) => {
  120. getList();
  121. allDay.value = [];
  122. config.value.splice(5, config.value.length - 5);
  123. let days = getDateAllDay(val);
  124. let list = [];
  125. for (let i = 0; i < days.length; i++) {
  126. const ele = days[i];
  127. list.push({
  128. key: "day" + ele,
  129. day: ele,
  130. });
  131. let attrs = {
  132. label: `${ele.substr(8, 10)}`,
  133. slot: "day" + ele,
  134. isNeedHeaderSlot: false,
  135. width: 35,
  136. align: "center",
  137. fixed: "right",
  138. };
  139. config.value.push({
  140. attrs,
  141. });
  142. }
  143. allDay.value = list;
  144. };
  145. const isOverdueData = ref([
  146. {
  147. label: "是",
  148. value: "1",
  149. },
  150. {
  151. label: "否",
  152. value: "0",
  153. },
  154. ]);
  155. const selectConfig = computed(() => [
  156. {
  157. label: "工厂",
  158. prop: "companyId",
  159. data: companyData.value,
  160. },
  161. {
  162. label: "是否逾期",
  163. prop: "isOverdue",
  164. data: isOverdueData.value,
  165. },
  166. {
  167. type: "time",
  168. itemType: "month",
  169. label: "排程日期",
  170. placeholder: "请选择生产日期",
  171. prop: "beginDate",
  172. clearable: false,
  173. placeholderOne: "",
  174. propOne: "",
  175. fn: (val) => {
  176. changDay(val);
  177. },
  178. },
  179. ]);
  180. const config = ref([
  181. {
  182. attrs: {
  183. label: "工厂",
  184. prop: "companyName",
  185. width: 100,
  186. align: "center",
  187. },
  188. },
  189. {
  190. attrs: {
  191. label: "生产订单号",
  192. prop: "code",
  193. width: 130,
  194. align: "center",
  195. },
  196. },
  197. {
  198. attrs: {
  199. label: "生产日期",
  200. slot: "date",
  201. width: 200,
  202. align: "center",
  203. },
  204. },
  205. {
  206. attrs: {
  207. label: "是否逾期",
  208. slot: "isOverdue",
  209. width: 60,
  210. align: "center",
  211. },
  212. },
  213. {
  214. attrs: {
  215. label: "产品",
  216. slot: "product",
  217. "min-width": 280,
  218. // align: "center",
  219. },
  220. },
  221. ]);
  222. const getList = (req) => {
  223. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  224. loading.value = true;
  225. proxy.post("/produceOrder/schedulingList", sourceList.value.pagination).then(
  226. (res) => {
  227. sourceList.value.data = res.map((x, index) => ({
  228. ...x,
  229. // id: "id" + index,
  230. produceTimeOne: x.produceTime,
  231. produceTime: x.produceTime.substr(0, 10),
  232. deliveryPeriod: x.deliveryPeriod.substr(0, 10),
  233. }));
  234. // sourceList.value.pagination.total = res.total;
  235. setTimeout(() => {
  236. loading.value = false;
  237. }, 200);
  238. },
  239. (err) => {
  240. loading.value = false;
  241. }
  242. );
  243. };
  244. changDay(str);
  245. const isAddClass = (day, index) => {
  246. if (index >= 0 && sourceList.value.data[index]) {
  247. let row = sourceList.value.data[index];
  248. let start = new Date(row.produceTime).getTime();
  249. let end = new Date(row.deliveryPeriod + " 23:59:59").getTime();
  250. let now = new Date(day + " 23:59:59").getTime();
  251. if (now >= start && now <= end) {
  252. return true;
  253. } else {
  254. return false;
  255. }
  256. }
  257. };
  258. const isAddLeftClass = (day, index) => {
  259. if (index >= 0 && sourceList.value.data[index]) {
  260. let row = sourceList.value.data[index];
  261. let start = row.produceTime;
  262. if (day.day == start) {
  263. return true;
  264. } else {
  265. return false;
  266. }
  267. }
  268. };
  269. const isAddRightClass = (day, index) => {
  270. if (index >= 0 && sourceList.value.data[index]) {
  271. let row = sourceList.value.data[index];
  272. let start = row.deliveryPeriod;
  273. if (day.day == start) {
  274. return true;
  275. } else {
  276. return false;
  277. }
  278. }
  279. };
  280. const isAddRedClass = (index) => {
  281. if (index >= 0 && sourceList.value.data[index]) {
  282. let row = sourceList.value.data[index];
  283. return row.isOverdue == "1";
  284. }
  285. };
  286. const formData = reactive({
  287. data: {},
  288. });
  289. const formOption = reactive({
  290. inline: true,
  291. labelWidth: 100,
  292. itemWidth: 100,
  293. });
  294. const productionFormDom = ref(null);
  295. const productionDialog = ref(false);
  296. const formLoading = ref(false);
  297. const productionFormConfig = computed(() => [
  298. {
  299. type: "date",
  300. itemType: "datetime",
  301. label: "投产时间",
  302. prop: "produceTime",
  303. // placeholder: "合同开始时间",
  304. itemWidth: 100,
  305. clearable: true,
  306. disabledFn: (date) => {
  307. return moment(date).isBefore(moment());
  308. },
  309. },
  310. ]);
  311. const productionRules = ref({
  312. produceTime: [
  313. { required: true, message: "请选择投产时间", trigger: "change" },
  314. ],
  315. });
  316. const clickDistributeProduction = (row) => {
  317. formData.data = {
  318. id: row.id,
  319. produceTime: row.produceTimeOne,
  320. };
  321. productionDialog.value = true;
  322. };
  323. const submitProduction = () => {
  324. productionFormDom.value.handleSubmit(() => {
  325. formLoading.value = true;
  326. proxy.post("/produceOrder/editProduceTime", formData.data).then((res) => {
  327. proxy.msgTip("操作成功");
  328. formLoading.value = false;
  329. productionDialog.value = false;
  330. getList();
  331. });
  332. });
  333. };
  334. const getDict = () => {
  335. proxy
  336. .get("/tenantDept/list", {
  337. pageNum: 1,
  338. pageSize: 9999,
  339. keyword: "",
  340. tenantId: proxy.useUserStore().user.tenantId,
  341. type: 0,
  342. })
  343. .then((res) => {
  344. companyData.value = res.data.map((x) => ({
  345. ...x,
  346. label: x.deptName,
  347. value: x.deptId,
  348. }));
  349. // treeData.value = proxy.handleTree(res.data, "deptId");
  350. });
  351. };
  352. getDict();
  353. </script>
  354. <style lang="scss" scoped>
  355. ::v-deep(.el-progress__text) {
  356. font-size: 14px !important;
  357. }
  358. .is-bk {
  359. background: #0066ff;
  360. }
  361. .left-class {
  362. border-radius: 6px 0 0 6px;
  363. }
  364. .right-class {
  365. border-radius: 0px 6px 6px 0px;
  366. }
  367. .all-class {
  368. border-radius: 6px !important ;
  369. }
  370. :deep(.el-table .cell) {
  371. padding: 0px !important;
  372. font-size: 12px;
  373. line-height: 28px;
  374. }
  375. .red {
  376. background: red;
  377. border-radius: 2px;
  378. padding: 4px;
  379. color: #fff;
  380. }
  381. .red-class {
  382. background: red !important;
  383. }
  384. </style>