123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689 |
- <template>
- <div class="tenant">
- <div class="content">
- <byTable
- :source="sourceList.data"
- :pagination="sourceList.pagination"
- :config="config"
- :loading="loading"
- highlight-current-row
- :selectConfig="selectConfig"
- :table-events="{
- select: select,
- }"
- :action-list="[
- {
- text: '添加任务',
- action: () => openModal('add'),
- },
- ]"
- @get-list="getList"
- >
- </byTable>
- </div>
- <el-dialog
- :title="modalType == 'add' ? '添加任务' : '查看任务'"
- v-model="dialogVisible"
- width="700"
- v-loading="loading"
- destroy-on-close
- :before-close="handleClose"
- >
- <byForm
- :formConfig="formConfig"
- :formOption="formOption"
- v-model="formData.data"
- :rules="rules"
- ref="byform"
- v-if="modalType == 'add'"
- >
- <template
- v-for="(cur, index) in productionProcessesList"
- :key="cur.id"
- v-slot:[cur.id]="{ item }"
- >
- <el-select
- v-model="productionObj[cur.id]"
- multiple
- placeholder="请选择负责人"
- >
- <el-option
- v-for="item in userList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </template>
- </byForm>
- <byForm
- :formConfig="formConfigOne"
- :formOption="formOptionOne"
- v-model="formData.dataOne"
- ref="byformOne"
- v-else
- >
- <template #list>
- <div style="width: 100%">
- <el-table :data="formData.dataOne.productionTaskDetailList">
- <el-table-column prop="productSn" label="产品SN" />
- <el-table-column
- prop="productionProcessesName"
- label="当前工序"
- />
- <el-table-column prop="cumulativeTime" label="累计耗时" />
- <el-table-column
- label="工序状态"
- prop="processesStatus"
- :formatter="
- (row) =>
- dictValueLabel(row.processesStatus, processesStatusData)
- "
- />
- </el-table>
- </div>
- </template>
- </byForm>
- <template #footer>
- <el-button @click="handleClose" size="large">取 消</el-button>
- <el-button
- type="primary"
- @click="submitForm()"
- size="large"
- :loading="submitLoading"
- v-if="modalType == 'add'"
- >
- 确 定
- </el-button>
- </template>
- </el-dialog>
- <el-dialog
- title="打印"
- v-if="printDialog"
- v-model="printDialog"
- width="500"
- >
- <div
- style="height: calc(100vh - 300px); overflow: auto; padding-right: 20px"
- >
- <div id="pdfDom">
- <div
- v-for="item in qrList"
- :key="item.productSn"
- style="border: 1px solid #000; padding: 10px; margin-bottom: 20px"
- >
- <div style="display: flex">
- <div :ref="item.productSn"></div>
- <div
- style="
- margin-left: 20px;
- display: flex;
- padding: 10px 0;
- flex-direction: column;
- justify-content: space-between;
- "
- >
- <div class="print-row">产品:{{ printData.productName }}</div>
- <div class="print-row">客户:{{ printData.customerName }}</div>
- </div>
- </div>
- <div
- style="
- font-size: 16px;
- font-weight: 700;
- color: #000;
- margin-top: 10px;
- "
- >
- {{ item.productSn }}
- </div>
- <!-- 换页 -->
- <div style="page-break-after: always"></div>
- </div>
- </div>
- </div>
- <template #footer>
- <el-button @click="printDialog = false" size="large">取 消</el-button>
- <el-button type="primary" v-print="printObj" size="large"
- >打 印</el-button
- >
- </template>
- </el-dialog>
- </div>
- </template>
- <script setup>
- import { ElMessage, ElMessageBox } from "element-plus";
- import byTable from "@/components/byTable/index";
- import byForm from "@/components/byForm/index";
- import useUserStore from "@/store/modules/user";
- import QRCode from "qrcodejs2-fix";
- const { proxy } = getCurrentInstance();
- const loading = ref(false);
- const submitLoading = ref(false);
- const sourceList = ref({
- data: [],
- pagination: {
- total: 3,
- pageNum: 1,
- pageSize: 10,
- keyword: "",
- },
- });
- const processesStatusData = ref([
- {
- label: "未开始",
- value: "0",
- },
- {
- label: "进行中",
- value: "1",
- },
- {
- label: "驳回",
- value: "2",
- },
- {
- label: "完成",
- value: "3",
- },
- ]);
- const dialogVisible = ref(false);
- const modalType = ref("add");
- const rules = ref({
- productionPlanId: [
- { required: true, message: "请选择生产计划", trigger: "change" },
- ],
- dueDate: [{ required: true, message: "请选择完成期限", trigger: "change" }],
- quantity: [{ required: true, message: "请输入生产数量", trigger: "blur" }],
- });
- const selectConfig = reactive([]);
- const config = computed(() => {
- return [
- {
- attrs: {
- label: "计划单号",
- prop: "productionPlanCode",
- },
- },
- {
- attrs: {
- label: "任务编码",
- prop: "code",
- },
- },
- {
- attrs: {
- label: "产品名称",
- prop: "productName",
- },
- },
- {
- attrs: {
- label: "规格型号",
- prop: "productSpec",
- },
- },
- {
- attrs: {
- label: "任务数量",
- prop: "quantity",
- },
- },
- {
- attrs: {
- label: "完成期限",
- prop: "dueDate",
- },
- },
- {
- attrs: {
- label: "操作",
- width: "120",
- align: "center",
- },
- renderHTML(row) {
- return [
- {
- attrs: {
- label: "查看",
- type: "primary",
- text: true,
- },
- el: "button",
- click() {
- getDtl(row);
- },
- },
- {
- attrs: {
- label: "打印",
- type: "primary",
- text: true,
- },
- el: "button",
- click() {
- handlePrint(row);
- },
- },
- ];
- },
- },
- ];
- });
- const formData = reactive({
- data: {},
- dataOne: {},
- });
- const formOption = reactive({
- inline: true,
- labelWidth: 100,
- itemWidth: 100,
- rules: [],
- });
- const formOptionOne = reactive({
- inline: true,
- labelWidth: 100,
- itemWidth: 100,
- rules: [],
- });
- const byform = ref(null);
- const formConfig = computed(() => {
- return [
- {
- type: "select",
- prop: "productionPlanId",
- label: "生产计划",
- required: true,
- filterable: true,
- data: planData.value,
- fn: (val) => {
- changeFn(val);
- },
- style: {
- width: "50%",
- },
- },
- {
- type: "input",
- itemType: "text",
- prop: "productName",
- label: "产品名称",
- disabled: true,
- style: {
- width: "50%",
- },
- },
- {
- type: "input",
- itemType: "text",
- prop: "productSpec",
- label: "规格型号",
- disabled: true,
- style: {
- width: "50%",
- },
- },
- {
- type: "input",
- itemType: "text",
- prop: "waitQuantity",
- label: "待排程数量",
- disabled: true,
- style: {
- width: "50%",
- },
- },
- {
- type: "number",
- prop: "quantity",
- label: "任务数量",
- precision: 0,
- min: 1,
- controls: false,
- style: {
- width: "50%",
- },
- },
- {
- type: "date",
- itemType: "date",
- prop: "dueDate",
- label: "完成期限",
- required: true,
- style: {
- width: "50%",
- },
- },
- ];
- });
- const formConfigOne = computed(() => {
- return [
- {
- type: "select",
- prop: "productionPlanId",
- label: "生产计划",
- required: true,
- filterable: true,
- data: planDataOne.value,
- fn: (val) => {
- changeFn(val);
- },
- style: {
- width: "50%",
- },
- },
- {
- type: "input",
- itemType: "text",
- prop: "productName",
- label: "产品名称",
- disabled: true,
- style: {
- width: "50%",
- },
- },
- {
- type: "input",
- itemType: "text",
- prop: "productSpec",
- label: "规格型号",
- disabled: true,
- style: {
- width: "50%",
- },
- },
- {
- type: "input",
- itemType: "text",
- prop: "waitQuantity",
- label: "待排程数量",
- disabled: true,
- style: {
- width: "50%",
- },
- isShow: modalType.value == "add",
- },
- {
- type: "number",
- prop: "quantity",
- label: "任务数量",
- precision: 0,
- min: 1,
- controls: false,
- style: {
- width: "50%",
- },
- },
- {
- type: "date",
- itemType: "date",
- prop: "dueDate",
- label: "完成期限",
- required: true,
- style: {
- width: "50%",
- },
- },
- {
- type: "slot",
- slotName: "list",
- label: "产品明细",
- },
- ];
- });
- const getList = async (req) => {
- sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
- loading.value = true;
- proxy
- .post("/productionTask/page", sourceList.value.pagination)
- .then((message) => {
- sourceList.value.data = message.rows;
- sourceList.value.pagination.total = message.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- const openModal = () => {
- dialogVisible.value = true;
- modalType.value = "add";
- formOption.disabled = false;
- formData.data = {};
- };
- const submitForm = () => {
- byform.value.handleSubmit(() => {
- if (Number(formData.data.quantity) > Number(formData.data.waitQuantity)) {
- return ElMessage({
- message: "任务数量不可大于待排程数量",
- type: "info",
- });
- }
- // if (proxy.compareTime(formData.data.startDate, formData.data.dueDate)) {
- // return ElMessage({
- // message: "完成期限不可小于计划开始时间",
- // type: "info",
- // });
- // }
- for (const key in productionObj.value) {
- if (productionObj.value[key] && productionObj.value[key].length > 0) {
- } else {
- return ElMessage({
- message: "所有工序都需选择负责人!",
- type: "info",
- });
- }
- }
- formData.data.taskProcessesUser = JSON.stringify(productionObj.value);
- submitLoading.value = true;
- proxy.post("/productionTask/addByJxst", formData.data).then(
- () => {
- ElMessage({
- message: "添加成功",
- type: "success",
- });
- handleClose();
- submitLoading.value = false;
- getList();
- getDict();
- },
- (err) => {
- console.log(err);
- submitLoading.value = false;
- }
- );
- });
- };
- const getDtl = (row) => {
- modalType.value = "detail";
- formOptionOne.disabled = true;
- proxy.post("/productionTask/detailByJxst", { id: row.id }).then((res) => {
- formData.dataOne = res;
- formData.dataOne.waitQuantity = res.remainingQuantity;
- dialogVisible.value = true;
- });
- };
- const userList = ref([]);
- const planData = ref([]);
- const planDataOne = ref([]);
- const statusData = ref([
- {
- label: "未开始",
- value: "0",
- },
- {
- label: "进行中",
- value: "1",
- },
- {
- label: "完成",
- value: "2",
- },
- ]);
- const getDict = () => {
- proxy
- .get("/tenantUser/list", {
- pageNum: 1,
- pageSize: 10000,
- tenantId: useUserStore().user.tenantId,
- })
- .then((res) => {
- userList.value = res.rows.map((item) => {
- return {
- label: item.nickName,
- value: item.userId,
- };
- });
- });
- proxy
- .post("/productionPlan/page", {
- pageNum: 1,
- pageSize: 9999,
- isRemaining: "1",
- })
- .then((res) => {
- planData.value = res.rows.map((x) => ({
- label: x.code + `(${x.startDate}-${x.stopDate})`,
- value: x.id,
- ...x,
- }));
- });
- proxy
- .post("/productionPlan/page", {
- pageNum: 1,
- pageSize: 9999,
- })
- .then((res) => {
- planDataOne.value = res.rows.map((x) => ({
- label: x.code,
- value: x.id,
- ...x,
- }));
- });
- };
- getDict();
- getList();
- const changeId = ref("");
- const changeFn = (val) => {
- const current =
- modalType.value == "add"
- ? planData.value.find((x) => x.value == val)
- : planDataOne.value.find((x) => x.value == val);
- if (current) {
- formData.data.productName = current.productName;
- formData.data.productSpec = current.productSpec;
- formData.data.waitQuantity = current.remainingQuantity;
- }
- if (
- productionProcessesList.value &&
- productionProcessesList.value.length > 0
- ) {
- // changeId.value = productionProcessesList.value[0].id;
- // const index = formConfig.value.findIndex(
- // (x) => x.slotName === changeId.value
- // );
- formConfig.value.splice(6, productionProcessesList.value.length);
- productionProcessesList.value = [];
- productionObj.value = {};
- }
- getProductionDetails(val);
- };
- const productionProcessesList = ref([]);
- const productionObj = ref({});
- const getProductionDetails = (id) => {
- proxy.post("/productionPlan/detail", { id }).then((res) => {
- productionProcessesList.value = res.productionProcessesList;
- for (let i = 0; i < productionProcessesList.value.length; i++) {
- const e = productionProcessesList.value[i];
- formConfig.value.push({
- type: "slot",
- label: e.name + " 负责人",
- slotName: e.id,
- });
- productionObj.value[e.id] = [];
- }
- });
- };
- const handleClose = () => {
- if (
- productionProcessesList.value &&
- productionProcessesList.value.length > 0
- ) {
- formConfig.value.splice(6, productionProcessesList.value.length);
- }
- productionProcessesList.value = [];
- productionObj.value = {};
- dialogVisible.value = false;
- };
- const printDialog = ref(false);
- const printData = ref({});
- const qrList = ref([]);
- const handlePrint = (row) => {
- const { code, quantity } = row;
- const arr = [];
- for (let i = 0; i < quantity; i++) {
- let key = i + 1 + "";
- key = key.padStart(3, "0");
- let obj = {
- productSn: code + "-" + key,
- };
- arr.push(obj);
- }
- qrList.value = arr;
- printData.value = {
- customerName: row.customerName,
- productName: row.productName + `(${row.productSpec})`,
- };
- printDialog.value = true;
- nextTick(() => {
- for (let i = 0; i < qrList.value.length; i++) {
- const ele = qrList.value[i];
- proxy.$refs[ele.productSn][0].innerHTML = ""; //清除二维码方法一
- new QRCode(proxy.$refs[ele.productSn][0], {
- text: ele.productSn, //页面地址 ,如果页面需要参数传递请注意哈希模式#
- width: 100,
- height: 100,
- colorDark: "#000000",
- colorLight: "#ffffff",
- correctLevel: QRCode.CorrectLevel.H,
- });
- }
- });
- };
- const printObj = ref({
- id: "pdfDom",
- popTitle: "",
- 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",
- extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
- });
- </script>
- <style lang="scss" scoped>
- .tenant {
- padding: 20px;
- }
- ::v-deep(.el-input-number .el-input__inner) {
- text-align: left;
- }
- .print-row {
- font-size: 14px;
- font-weight: 700;
- color: #000;
- }
- </style>
|