index.vue 9.9 KB

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