index.vue 10 KB

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