ezhizao_zx 1 yıl önce
ebeveyn
işleme
e65edb45b7

+ 6 - 1
src/views/business/entrust/workOrderForFactory/currentMonth/index.vue

@@ -148,7 +148,11 @@
         </template>
       </el-table-column>
     </el-table>
-    <!-- <contract-form ref="contractRef" :get-list="getList" /> -->
+    <init-month-dialog
+      ref="initMonthDialogRef"
+      :get-list="checkCurrentMonthHandle"
+      :setCurrentMonth="setCurrentMonth"
+    />
     <!-- 分页 -->
     <pagination
       v-show="total > 0"
@@ -169,6 +173,7 @@ import {
   delEntrust,
   transNextForFactory,
 } from "@/api/business/entrust/currentWorkOrder";
+import InitMonthDialog from "../initMonthDialog";
 import useUserStore from "@/store/modules/user";
 
 const { proxy } = getCurrentInstance();

+ 94 - 0
src/views/business/entrust/workOrderForFactory/initMonthDialog.vue

@@ -0,0 +1,94 @@
+<template>
+  <el-dialog
+    title="设置当前工作月"
+    v-model="formOpen"
+    width="500px"
+    append-to-body
+    draggable
+    @close="cancel"
+  >
+    <el-form ref="dictRef" :model="form" label-width="100">
+      <el-form-item label="当前工作月:">
+        <el-date-picker
+          v-model="currentMonth"
+          size="small"
+          placeholder="起始月"
+          :clearable="true"
+          value-format="YYYY-MM-01"
+          format="YYYY年MM月"
+          type="month"
+        />
+      </el-form-item>
+    </el-form>
+    <template #footer>
+      <div class="dialog-footer">
+        <el-button
+          type="primary"
+          icon="Finished"
+          size="small"
+          @click="submitForm"
+          >确 定</el-button
+        >
+        <el-button icon="close" size="small" @click="cancel">取 消</el-button>
+      </div>
+    </template>
+  </el-dialog>
+</template>
+<script setup>
+import { initCurrentMonth } from "@/api/business/entrust/currentWorkOrder";
+import { ref } from "vue";
+
+const { proxy } = getCurrentInstance();
+
+const props = defineProps({
+  getList: {
+    type: Function,
+    default: () => {},
+  },
+  setCurrentMonth: {
+    type: Function,
+    default: () => {},
+  },
+});
+
+const { getList, setCurrentMonth } = toRefs(props);
+const currentMonth = ref(proxy.moment().format("YYYY-MM-01"));
+
+const formOpen = ref(false);
+const form = ref({});
+
+function submitForm() {
+  if (currentMonth.value == null || currentMonth.value == "") {
+    proxy.$modal.msgError("请选择月份!");
+    return;
+  }
+  initCurrentMonth({
+    year: currentMonth.value.substring(0, 4),
+    month: currentMonth.value.substring(5, 7),
+  }).then((response) => {
+    proxy.$modal.msgSuccess("设置完成!");
+    formOpen.value = false;
+    setCurrentMonth.value(proxy.moment().format("YYYY-MM-01"));
+    cancel();
+    getList.value();
+  });
+}
+
+function cancel() {
+  formOpen.value = false;
+  reset();
+}
+
+function open(options) {
+  formOpen.value = true;
+}
+
+function reset() {
+  currentMonth.value = proxy.moment().format("YYYY-MM-01");
+}
+
+// 暴露给父组件的方法
+defineExpose({
+  open,
+});
+</script>

+ 184 - 0
src/views/business/entrust/workOrderForFactory/setEntrustDialog.vue

@@ -0,0 +1,184 @@
+<template>
+  <el-dialog
+    title="设置委托"
+    v-model="formOpen"
+    width="900px"
+    append-to-body
+    draggable
+    @close="cancel"
+  >
+    <el-form ref="dictRef" :model="form" label-width="100">
+      <el-form-item label="受委托方:">
+        <el-select placeholder="请选择受委托方" v-model="toTenantId">
+          <el-option
+            v-for="(item, index) in factories"
+            :key="index"
+            :label="item.accountName"
+            :value="item.id"
+          ></el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item label="委托工单:">
+        <el-table
+          :data="list"
+          size="small"
+          border
+          height="100%"
+          @selection-change="handleSelectionChange"
+        >
+          <el-table-column
+            label="客户名称"
+            align="center"
+            min-width="250"
+            prop="companyName"
+          />
+          <el-table-column
+            label="税号"
+            align="center"
+            prop="socialCreditCode"
+            min-width="180"
+          />
+          <el-table-column
+            label="工单类型"
+            align="center"
+            prop="amount"
+            width="80"
+          >
+            <template #default="scope">
+              {{ scope.row.type === 1 ? "循环工单" : "代办工单" }}
+            </template>
+          </el-table-column>
+          <el-table-column
+            label="项目"
+            align="center"
+            prop="taskTypeName"
+            width="150"
+          >
+            <template #default="scope">
+              {{ scope.row.taskTypeName }}
+              {{
+                scope.row.taskTypeDetailName
+                  ? `-${scope.row.taskTypeDetailName}`
+                  : ""
+              }}
+            </template>
+          </el-table-column>
+          <el-table-column label="操作" align="center" width="50">
+            <template #default="scope">
+              <el-button
+                type="danger"
+                size="small"
+                link
+                @click="delWorkOrderHandler(scope.$index)"
+                >删除</el-button
+              >
+            </template>
+          </el-table-column>
+        </el-table>
+      </el-form-item>
+    </el-form>
+    <template #footer>
+      <div class="dialog-footer">
+        <el-button
+          type="primary"
+          icon="Finished"
+          size="small"
+          @click="submitForm"
+          >确 定</el-button
+        >
+        <el-button @click="cancel" icon="close" size="small">取 消</el-button>
+      </div>
+    </template>
+  </el-dialog>
+</template>
+<script setup>
+import {
+  addEntrust,
+  getFactories,
+} from "@/api/business/entrust/currentWorkOrder";
+import { ref } from "vue";
+
+const { proxy } = getCurrentInstance();
+
+const factories = ref([]);
+const emit = defineEmits(["choice"]);
+
+const toTenantId = ref(null);
+
+const list = ref([]);
+
+const props = defineProps({
+  getList: {
+    type: Function,
+    default: () => {},
+  },
+});
+
+const { getList } = toRefs(props);
+const currentMonth = ref(proxy.moment().format("YYYY-MM-01"));
+
+const formOpen = ref(false);
+const form = ref({});
+const rules = ref({});
+const content = ref("请输入员工姓名");
+const ids = ref([]);
+
+function submitForm() {
+  if (toTenantId.value == null || toTenantId.value == "") {
+    proxy.$modal.msgError("请选择受委托方!");
+    return;
+  }
+  if (list.value.length == 0) {
+    proxy.$modal.msgError("请选择要委托的工单!");
+    return;
+  }
+  const entrust = {
+    workMonth: currentMonth.value,
+    toTenantId: toTenantId.value,
+    workOrderIds: list.value.map((l) => l.id),
+  };
+  emit("submit", entrust);
+  // addEntrust(entrust).then((response) => {
+  //   proxy.$modal.msgSuccess("设置完成!");
+  //   formOpen.value = false;
+  //   cancel()
+  //   getList.value()
+  // });
+}
+
+function cancel() {
+  formOpen.value = false;
+  reset();
+}
+
+function open(options) {
+  const { optionCurrentMonth, selections } = options;
+  currentMonth.value = optionCurrentMonth;
+  list.value = proxy.deepClone(selections);
+  formOpen.value = true;
+}
+
+function delWorkOrderHandler(index) {
+  proxy.$modal.confirm("是否确认删除选中的数据项?").then(() => {
+    list.value.splice(index, 1);
+  });
+}
+
+function reset() {
+  list.value = [];
+  currentMonth.value = proxy.moment().format("YYYY-MM-01");
+  toTenantId.value = null;
+}
+
+function initFactories() {
+  getFactories().then((res) => {
+    factories.value = res.data;
+  });
+}
+initFactories();
+// 暴露给父组件的方法
+defineExpose({
+  open,
+  cancel,
+});
+</script>