chengxiangling
2025-05-14 9587438965a876c23b9e9efcff014f1cc565cb4d
src/views/basicData/calendar/index.vue
@@ -7,68 +7,45 @@
      :inline="true"
      v-show="showSearch"
      label-width="68px"
      label-position="left"
    >
      <el-row type="flex" justify="right">
        <el-form-item label="日历描述" prop="description">
          <el-input
            style="width: 140px"
            v-model="queryParams.description"
            placeholder="请输入描述关键词"
            clearable
            @keyup.enter="handleQuery"
          />
        </el-form-item>
        <el-form-item label="日历类型" prop="effectiveDate">
          <el-select clearable v-model="dateType" style="width: 90px">
            <el-option
              v-for="(item, index) of dateTypeList"
              :key="index"
              :label="item.name"
              :value="item.name"
              >{{ item.name }}</el-option
      <el-row type="flex" justify="left" :gutter="20">
        <el-col :span="5">
          <el-form-item label="日历描述" prop="description">
            <el-input
              style="width: 140px"
              v-model="queryParams.description"
              placeholder="请输入描述关键词"
              clearable
              @keyup.enter="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="适用工厂" prop="plant">
            <el-select
              style="width: 140px"
              clearable
              v-model="queryParams.plant"
              placeholder="适用工厂"
            >
          </el-select>
        </el-form-item>
        <el-form-item label="生效日期" prop="effectiveDate">
          <el-date-picker
            clearable
            v-model="queryParams.effectiveDate"
            type="date"
            value-format="YYYY-MM-DD"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="适用工厂" prop="expiringDate">
          <!-- <el-date-picker clearable
          v-model="queryParams.expiringDate"
          type="date"
          value-format="YYYY-MM-DD"
          placeholder="请选择失效日期">
        </el-date-picker> -->
          <el-input
            style="width: 180px"
            v-model="queryParams.description"
            placeholder="请输入工厂关键词"
            clearable
            @keyup.enter="handleQuery"
          />
        </el-form-item>
      </el-row>
      <el-row type="flex" justify="end">
        <el-form-item class="column-with-margin">
          <el-button type="primary" icon="Search" @click="handleQuery"
            >查询</el-button
          >
          <el-button icon="Refresh" @click="resetQuery">重置</el-button>
          <!-- <el-button
            type="success"
            icon="Plus"
            @click="handleAdd"
            v-hasPermi="['core:calendar:add']"
            >新增日历</el-button
          > -->
        </el-form-item>
              <el-option
                v-for="item in aps_factory"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="13" style="text-align: right">
          <el-form-item class="column-with-margin">
            <el-button type="primary" icon="Search" @click="handleQuery"
              >查询</el-button
            >
            <el-button icon="Refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
@@ -79,7 +56,7 @@
          plain
          icon="Plus"
          @click="handleAdd"
          v-hasPermi="['core:calendar:add']"
          v-hasPermi="['aps:calendar:add']"
          >新增</el-button
        >
      </el-col>
@@ -90,7 +67,7 @@
          icon="Edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['core:calendar:edit']"
          v-hasPermi="['aps:calendar:update']"
          >修改</el-button
        >
      </el-col>
@@ -101,11 +78,11 @@
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['core:calendar:remove']"
          v-hasPermi="['aps:calendar:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
      <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          plain
@@ -114,7 +91,7 @@
          v-hasPermi="['core:calendar:export']"
          >导出</el-button
        >
      </el-col>
      </el-col> -->
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="getList"
@@ -126,22 +103,70 @@
      :data="calendarList"
      :loading="loading"
      :height="height"
      ref="tableRef"
      :page="page"
      @changePageNo="changePageNo"
      @changePageSize="changePageSize"
      @on-checkbox="handleCheckboxChange"
      class="auto-height-grid"
    >
      <template #status="{ row }">
        <vxe-tag v-if="row.type === '1'" status="primary">周工作日</vxe-tag>
        <vxe-tag v-if="row.type === '2'" status="success">节假日</vxe-tag>
      </template>
      <template #content="{ row }">
        <vxe-tag>周工作日</vxe-tag>
      <template #mark="{ row }">
        <div v-if="row.type === '1'">
          <span
            v-for="(item, index) in JSON.parse(row.content.value).weekdays"
            :key="index"
          >
            <span v-if="item.work === 'y'" status="success" class="mart5"
              >{{ item.chineseName }}: 工作日;&nbsp;</span
            >
            <span v-if="item.work === 'n'" status="info" class="mart5"
              >{{ item.chineseName }}: 非工作日;&nbsp;</span
            >
          </span>
          <!-- <div v-for="(item, index) in JSON.parse(row.content.value).weekdays" :key="index">
              <vxe-tag v-if="item.work==='y'" status="success" class="mart5">{{item.chineseName}}: 工作日;&nbsp;</vxe-tag>
              <vxe-tag v-if="item.work==='n'" status="info" class="mart5">{{item.chineseName}}: 非工作日;&nbsp;</vxe-tag>
            </div> -->
        </div>
        <div v-if="row.type === '2'">
          <div>
            {{ JSON.parse(row.content.value).holidays.startdate }}至{{
              JSON.parse(row.content.value).holidays.enddate
            }}
          </div>
        </div>
      </template>
      <template #buttons="{ row }">
        <el-button
          type="primary"
          size="small"
          @click="handleUpdate(row)"
          v-hasPermi="['aps:calendar:update']"
          >修改</el-button
        >
        <el-button
          type="warning"
          size="small"
          @click="handleSetHolidays(row)"
          v-hasPermi="['aps:calendar:remove']"
          >设置节假日</el-button
        >
        <el-button
          type="danger"
          size="small"
          @click="handleDelete(row)"
          v-hasPermi="['aps:calendar:remove']"
          >删除</el-button
        >
      </template>
    </HxlhTable>
    <!-- 添加或修改日历管理对话框 -->
    <el-dialog :title="title" v-model="open" width="500px" append-to-body>
    <el-dialog :title="title" v-model="open" width="80%" append-to-body>
      <el-form
        ref="calendarRef"
        :model="form"
@@ -152,10 +177,11 @@
          <el-input v-model="form.description" placeholder="请输入描述" />
        </el-form-item>
        <el-form-item label="日历类型" prop="type">
          <el-radio-group v-model="form.type" @change="handleSwitchType">
            <el-radio :label="1">周工作</el-radio>
            <el-radio :label="2">节假日</el-radio>
          </el-radio-group>
          <!-- <el-radio-group v-model="form.type" @change="handleSwitchType">
            <el-radio :label="'1'">周工作</el-radio>
            <el-radio :label="'2'">节假日</el-radio>
          </el-radio-group> -->
          <el-tag type="primary">周工作</el-tag>
        </el-form-item>
        <el-form-item label="生效时间" prop="effectiveDate">
          <el-date-picker
@@ -177,7 +203,7 @@
          >
          </el-date-picker>
        </el-form-item>
        <div v-if="form.type === 1">
        <div>
          <div class="title_bar_line">
            <div class="line_short"></div>
            <div>周工作设置</div>
@@ -190,14 +216,14 @@
          >
            <div class="week_flex_item">{{ item.chineseName }}</div>
            <div class="week_flex_item">
              <el-radio-group v-model="item.work" @change="handleSetWorkDays">
              <el-radio-group v-model="item.work">
                <el-radio :label="'y'">工作日</el-radio>
                <el-radio :label="'n'">非工作日</el-radio>
              </el-radio-group>
            </div>
          </div>
        </div>
        <div v-if="form.type === 2">
        <div v-if="form.type === '2'">
          <div class="title_bar_line">
            <div class="line_short"></div>
            <div>节假日设置</div>
@@ -230,67 +256,105 @@
            </div>
          </div>
        </div>
        <el-form-item
        <!-- <el-form-item
          label="适用工厂"
          prop="applicableFactory"
          class="factory_use_item"
        > -->
        <div class="select_factory select_factory_dis">适用工厂/车间/工序</div>
        <!-- <el-row :gutter="20" class="select_factory"> -->
        <div
          class="select_factory_dis"
          v-for="(item, index) in applicableSettingList"
          :key="index"
        >
          <!-- <el-col :span="7"> -->
          <el-select
            class="select_content"
            clearable
            v-model="form.applicableFactory"
            v-model="item.factory"
            style="width: 160px"
            placeholder="请输入适用工厂"
            @change="changePlant($event)"
          >
            <el-option
              v-for="plant in plantList"
              :key="plant.id"
              :label="plant.plantName"
              :value="plant.plantCode"
              v-for="plant in aps_factory"
              :key="plant.value"
              :label="plant.label"
              :value="`${plant.value};${plant.label}`"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="适用车间"
          prop="applicableWorkshop"
          class="factory_use_item"
        >
          <!-- </el-col>
              <el-col :span="7"> -->
          <el-select
            class="select_content"
            clearable
            v-model="form.applicableWorkshop"
            v-model="item.workshop"
            style="width: 160px"
            placeholder="请输入适用车间"
            @change="changeWorkshop($event)"
          >
            <el-option
              v-for="shop in shopList"
              :key="shop.id"
              :label="shop.shopName"
              :value="shop.id"
              :value="`${shop.id};${shop.shopName}`"
            >
            </el-option>
          </el-select>
          <!-- </el-col>
              <el-col :span="7"> -->
          <el-select
            class="select_content"
            clearable
            v-model="item.process"
            style="width: 160px"
            placeholder="请输入适用工序"
          >
            <el-option
              v-for="process in processList"
              :key="process.processNumber"
              :label="process.processName"
              :value="`${process.processNumber};${process.processName}`"
            >
            </el-option>
          </el-select>
          <!-- </el-col>
              <el-col :span="3"> -->
          <el-button
            class="select_content"
            type="primary"
            icon="Plus"
            @click="handleAddFactory(item)"
            circle
            size="small"
          />
          <el-button
            v-if="applicableSettingList.length > 1"
            class="select_content"
            type="primary"
            icon="Minus"
            @click="handleMinusFactory(item)"
            circle
            size="small"
          />
          <!-- </el-col> -->
        </div>
        <!-- </el-row> -->
        <!-- </el-form-item> -->
        <!-- <el-form-item
          label="适用车间"
          prop="applicableWorkshop"
          class="factory_use_item"
        >
        </el-form-item>
        <el-form-item
          label="适用工序"
          prop="applicableProcess"
          class="factory_use_item"
        >
          <el-select
            clearable
            v-model="form.applicableProcess"
            style="width: 160px"
            placeholder="请输入适用工序"
          >
            <el-option
              v-for="process in processList"
              :key="process.id"
              :label="process.processName"
              :value="process.processName"
            >
            </el-option>
          </el-select>
        </el-form-item>
        </el-form-item> -->
      </el-form>
      <template #footer>
        <div class="dialog-footer">
@@ -299,10 +363,115 @@
        </div>
      </template>
    </el-dialog>
    <el-dialog
      title="设置节假日"
      v-model="openSetHolidays"
      width="80%"
      style="height: 570px"
      append-to-body
    >
      <div class="height_dialog">
        <div class="height_dialog_scroll">
          <div class="grey_bg">
            <div v-if="expand">
              <div class="flex_item">
                <div>工作日历:&nbsp;</div>
                <div>{{ form.description }}</div>
              </div>
              <div class="flex_item">
                <div>生效时间:&nbsp;</div>
                <div>{{ form.effectiveDate }}</div>
              </div>
              <div class="flex_item">
                <div>失效时间:&nbsp;</div>
                <div>{{ form.expiringDate }}</div>
              </div>
              <div class="flex_item">
                <div>适用工厂:&nbsp;</div>
                <div class="flex_item_dis">
                  <div
                    v-for="(item, index) in form.applicableTranslate"
                    :key="index"
                  >
                    {{ item.factory }} - {{ item.workshop }} - {{ item.process }}
                  </div>
                </div>
              </div>
            </div>
            <div class="flex_item_expand_end" @click="handleToggleExpand">
              <el-icon :size="18" v-if="expand"><ArrowUpBold /></el-icon>
              <el-icon v-else><ArrowDownBold /></el-icon>
            </div>
          </div>
          <div class="title_flex">
            <div class="holiday_title">节假日列表</div>
            <el-button type="primary" size="small" @click="hanldeAddHolidays"
              >添加节假日</el-button
            >
          </div>
          <div class="grey_bg">
          <el-form
            class="mart10"
            ref="holidaysRef"
            :model="formHolidays"
            :rules="holidayRules"
            :inline="true"
            label-width="105px"
          >
            <template v-for="(item, index) in formHolidays" :key="index">
              <el-form-item label="节假日描述" prop="description">
                <el-input
                  style="width: 130px"
                  v-model="item.describe"
                  placeholder="请输入描述"
                />
              </el-form-item>
              <el-form-item label="开始时间" prop="startdate">
                <el-date-picker
                  style="width: 130px"
                  clearable
                  v-model="item.startdate"
                  type="date"
                  :disabled-date="handleDisabledDate"
                  :default-value="form.effectiveDate"
                  placeholder="选择日期"
                >
                </el-date-picker>
              </el-form-item>
              <el-form-item label="结束时间" prop="enddate">
                <el-date-picker
                  style="width: 130px"
                  clearable
                  v-model="item.enddate"
                  type="date"
                  placeholder="选择日期"
                  :disabled-date="handleDisabledDate"
                  :default-value="form.expiringDate"
                >
                </el-date-picker>
              </el-form-item>
              <el-form-item label="" prop="">
                <el-button v-if="formHolidays.length>1" type="danger" size="small" @click="handleDelSettingHolidays(item)">删除</el-button>
              </el-form-item>
            </template>
          </el-form>
          </div>
        </div>
      </div>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="openSetHolidays = false">取 消</el-button>
          <el-button type="primary" @click="handleSaveHolidaysForm"
            >保存</el-button
          >
        </div>
      </template>
    </el-dialog>
  </div>
</template>
<script setup name="Calendar">
import moment from "moment";
import HxlhTable from "@/components/HxlhTable";
import {
  listCalendar,
@@ -311,12 +480,18 @@
  addCalendar,
  updateCalendar,
} from "@/api/basicData/calendar";
import { listAll_plant } from "@/api/basicData/plant";
import axios from "axios";
import { listAll_plant, listByWorkShop } from "@/api/basicData/plant";
import { listAll_shop, listAps_shop } from "@/api/basicData/shop";
import { selectProcessNameList } from "@/api/basicData/processRoute.js";
import { ElMessage } from "element-plus";
const { proxy } = getCurrentInstance();
const { aps_factory } = proxy.useDict("aps_factory");
const tableRef = ref();
const calendarList = ref([]);
const open = ref(false);
const openSetHolidays = ref(false);
const expand = ref(true);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
@@ -325,11 +500,28 @@
const total = ref(0);
const title = ref("");
const data = reactive({
  form: {},
  form: {
    type: "1",
    applicable: [
      {
        factory: "",
        workshop: "",
        process: "",
      },
    ],
  },
  formHolidays: [
    {
      enddate: "",
      startdate: "",
      describe: "",
    },
  ],
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    description: null,
    plant: null,
    type: null,
    effectiveDate: null,
    expiringDate: null,
@@ -346,13 +538,13 @@
        trigger: "blur",
      },
    ],
    type: [
      {
        required: true,
        message: "请选择日历类型",
        trigger: "blur",
      },
    ],
    // type: [
    //   {
    //     required: true,
    //     message: "请选择日历类型",
    //     trigger: "blur",
    //   },
    // ],
    effectiveDate: [
      {
        required: true,
@@ -367,26 +559,33 @@
        trigger: "blur",
      },
    ],
    applicableFactory: [
  },
  holidayRules: {
    describe: [
      {
        required: true,
        message: "请选择适用工厂",
        message: "请输入节假日描述",
        trigger: "blur",
      },
    ],
  },
});
const { queryParams, form, rules } = toRefs(data);
const { queryParams, form, rules, formHolidays, holidayRules } = toRefs(data);
const dateType = ref("周工作");
const dateTypeList = ref([
  {
    name: "周工作",
    label: "1",
  },
  {
    name: "节假日",
    label: "2",
  },
]);
const typeRadioNumber = ref(1);
const applicableSettingList = ref([
  { factory: "", workshop: "", process: "", id: 0 },
]);
const weekDaysSettingList = ref([
  {
    day: "Monday",
@@ -394,7 +593,7 @@
    work: "y",
  },
  {
    day: "TuesDay",
    day: "Tuesday",
    chineseName: "星期二",
    work: "y",
  },
@@ -432,7 +631,7 @@
const shopList = ref([]);
const allShopList = ref([]);
const processList = ref([]);
const height = ref(document.documentElement.clientHeight - 260 + "px;");
const height = ref(document.documentElement.clientHeight - 220 + "px;");
// 表格配置-列表
const columns = ref([
  { type: "checkbox", width: 60, align: "center" },
@@ -445,28 +644,28 @@
  {
    title: "日历类型",
    field: "type",
    width: 150,
    width: 200,
    align: "center",
    slots: { default: "status" },
  },
  {
    title: "日历生效时间",
    field: "effectiveDate",
    width: 100,
    width: 200,
    align: "center",
  },
  {
    title: "日历失效时间",
    field: "expiringDate",
    width: 150,
    width: 200,
    align: "center",
  },
  {
    title: "日历内容",
    field: "content",
    width: 200,
    width: 230,
    align: "center",
    slots: { default: "content" },
    slots: { default: "mark" },
  },
  {
    title: "适用工厂",
@@ -474,16 +673,11 @@
    width: 200,
    align: "center",
    formatter: ({ cellValue, row, column }) => {
      console.log(cellValue, "000hsudhwhuwhuhwu");
      for (let i = 0; i < plantList.value.length; i++) {
        console.log(
          cellValue,
          plantList.value[i].plantCode,
          plantList.value[i].plantName,
          "111hsudhwhuwhuhwu"
        );
        if (cellValue === plantList.value[i].plantCode) {
          return plantList.value[i].plantName;
      if (cellValue) {
        for (let i = 0; i < plantList.value.length; i++) {
          if (cellValue === plantList.value[i].plantCode) {
            return plantList.value[i].plantName;
          }
        }
      }
    },
@@ -491,37 +685,42 @@
  {
    title: "适用车间",
    field: "applicableWorkshop",
    width: 90,
    width: 200,
    align: "center",
    formatter: ({ cellValue, row, column }) => {
      console.log(row.applicableFactory, "llll");
      listAps_shop({ plantCode: row.applicableFactory }).then((response) => {
        console.log(response.rows, "适用车间");
        shopList.value = response.rows;
      });
      for (let i = 0; i < shopList.value.length; i++) {
        if (cellValue === shopList.value[i].id) {
          return shopList.value[i].shopName;
      if (cellValue) {
        for (let i = 0; i < shopList.value.length; i++) {
          if (cellValue === shopList.value[i].id) {
            return shopList.value[i].shopName;
          }
        }
      }
      return "";
    },
  },
  {
    title: "适用工序",
    field: "applicableProcess",
    width: 90,
    width: 200,
    align: "center",
  },
  {
    title: "创建者",
    field: "createBy",
    width: 90,
    width: 200,
    align: "center",
  },
  {
    title: "创建时间",
    field: "createTime",
    width: 90,
    width: 200,
    align: "center",
  },
  {
    title: "操作",
    width: 270,
    fixed: "right",
    slots: { default: "buttons" },
    align: "center",
  },
]);
@@ -533,41 +732,35 @@
});
/** 查询日历管理列表 */
async function getList() {
function getList() {
  loading.value = true;
  listCalendar(queryParams.value).then((response) => {
    calendarList.value = response.rows;
    total.value = response.total;
    page.value.total = response.total;
    loading.value = false;
  });
  const res = await listAll_plant({});
  plantList.value = res.data;
  axios
    .all([
      /** 查询工厂列表 */
      listAll_plant({}),
      /** 查询车间列表 */
      listAll_shop({}),
    ])
    .then(
      axios.spread((response1, response2) => {
        plantList.value = response1.data;
        shopList.value = response2.data;
        loading.value = false;
      })
    )
    .catch((error) => {
      console.error("请求出错:", error);
    });
}
// 取消按钮
function cancel() {
  open.value = false;
  reset();
}
// 表单重置
function reset() {
  form.value = {
    id: null,
    description: null,
    type: null,
    effectiveDate: null,
    expiringDate: null,
    content: null,
    applicableFactory: null,
    applicableWorkshop: null,
    applicableProcess: null,
    createBy: null,
    createTime: null,
    updateBy: null,
    updateTime: null,
  };
  proxy.resetForm("calendarRef");
}
/** 搜索按钮操作 */
@@ -591,69 +784,235 @@
/** 新增按钮操作 */
async function handleAdd() {
  reset();
  open.value = true;
  form.value = {
    applicable: [
      {
        factory: "",
        workshop: "",
        process: "",
      },
    ],
  };
  title.value = "添加日历管理";
  const res = await listAll_plant({});
  plantList.value = res.data;
  console.log(res, "sjchhscwhciwhcwi");
}
/** 选择工厂后事件 加载车间 和 工序 **/
function changePlant(plant) {
  listAps_shop({ plantCode: plant }).then((response) => {
    console.log(response, "sbcsuhcuhscschsc");
  console.log(plant);
  listAps_shop({ plantCode: plant.split(";")[0] }).then((response) => {
    shopList.value = response.rows;
  });
  selectProcessNameList({ orgCode: plant }).then((response) => {
    processList.value = response.rows;
  // selectProcessNameList({ orgCode: plant }).then((response) => {
  //   processList.value = response.rows;
  // });
}
function changeWorkshop(workShop) {
  console.log(workShop.split(";")[0]);
  listByWorkShop({ workShop: "气柜" }).then((res) => {
    console.log(res, "workShop");
    processList.value = res.rows;
  });
}
function handleAddFactory(row) {
  console.log(row);
  applicableSettingList.value.push({ ...row, id: ++row.id });
}
function handleMinusFactory(row) {
  applicableSettingList.value = applicableSettingList.value.filter(
    (item, index) => item !== row
  );
}
/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const _id = row.id || ids.value;
  getCalendar(_id).then((response) => {
    form.value = response.data;
    // form.value.content = JSON.parse(response.data.content.value);
    if (form.value.type === "1") {
      weekDaysSettingList.value = JSON.parse(
        response.data.content.value
      ).weekdays;
    } else if (form.value.type === "2") {
      holidays.value = JSON.parse(response.data.content.value).holidays;
    }
    open.value = true;
    title.value = "修改日历管理";
  });
}
// 设置节假日
function handleSetHolidays(row) {
  form.value = {
    ...row,
    applicableTranslate: JSON.parse(row.applicableTranslate),
  };
  if (!row.holidays) {
    formHolidays.value = [
      {
        enddate: "",
        startdate: "",
        describe: "",
      },
    ];
  } else {
    formHolidays.value = JSON.parse(row.holidays.value);
  }
  openSetHolidays.value = true;
}
// 禁用日期
function handleDisabledDate(date) {
  const targetDate = moment(date).valueOf();
  const startDate = moment(form.value.effectiveDate).valueOf();
  const endDate = moment(form.value.expiringDate).valueOf();
  console.log(targetDate, startDate, endDate, "handleDisabledDate");
  return targetDate < startDate || targetDate > endDate;
}
// 删除节假日设置
function handleDelSettingHolidays(row) {
 formHolidays.value = formHolidays.value.filter(item=>{
    return item != row
  })
}
// 添加节假日
function hanldeAddHolidays() {
  formHolidays.value.push({
    enddate: "",
    startdate: "",
    describe: "",
  });
}
function handleToggleExpand() {
  expand.value = !expand.value;
}
// 提交节假日
function handleSaveHolidaysForm() {
  proxy.$refs["holidaysRef"].validate((valid) => {
    if (valid) {
      updateCalendar({
        id: form.value.id,
        // content: {
        //   weekdays: weekDaysSettingList.value,
        // },
        holidays: formHolidays.value.map((item) => {
          return {
            startdate: moment(item.startdate).format("YY-MM-DD"),
            enddate: moment(item.enddate).format("YY-MM-DD"),
          };
        }),
        // applicable: applicableSettingList.value.map((item) => {
        //   return {
        //     factory: item.factory.split(";")[0],
        //     process: item.process.split(";")[0],
        //     workshop: item.workshop.split(";")[0],
        //   };
        // }),
        // applicableTranslate: JSON.stringify(
        //   applicableSettingList.value.map((item) => {
        //     return {
        //       factory: item.factory.split(";")[1],
        //       process: item.process.split(";")[1],
        //       workshop: item.workshop.split(";")[1],
        //     };
        //   })
        //),
        // applicableCn:
        //},
      }).then((response) => {
        proxy.$modal.msgSuccess("新增成功");
        open.value = false;
        getList();
      });
    }
  });
}
/** 提交按钮 */
function submitForm() {
  proxy.$refs["calendarRef"].validate((valid) => {
    if (valid) {
      if (applicableSettingList.value[0].factory === "") {
        ElMessage({
          type: "error",
          message: "至少选择一个适用工厂",
        });
        return;
      }
      if (form.value.id != null) {
        updateCalendar(form.value).then((response) => {
        // if (form.value.type === "1") {
        //   updateCalendar({
        //     ...form.value,
        //     content: {
        //       weekdays: weekDaysSettingList.value,
        //     },
        //     applicableWorkshop: form.value.applicableWorkshop,
        //     applicableProcess: form.value.applicableProcess,
        //   }).then((response) => {
        //     proxy.$modal.msgSuccess("修改成功");
        //     open.value = false;
        //     getList();
        //   });
        // } else if (form.value.type === "2") {
        updateCalendar({
          ...form.value,
          content: {
            holidays: holidays.value,
          },
          applicableWorkshop: form.value.applicableWorkshop.map((item) => {
            return {
              factory: item.factory.split(";")[0],
              process: item.process.split(";")[0],
              workshop: item.workshop.split(";")[0],
            };
          }),
          applicableProcess: form.value.applicableProcess,
        }).then((response) => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
        // }
      } else {
        if (typeRadioNumber.value === 1) {
          addCalendar({
            ...form.value,
            content: {
              weekdays: weekDaysSettingList.value,
            },
          }).then((response) => {
            proxy.$modal.msgSuccess("新增成功");
            open.value = false;
            getList();
          });
        }else if(typeRadioNumber.value === 2){
          addCalendar({
            ...form.value,
            content: {
              holidays: holidays.value,
            },
          }).then((response) => {
            proxy.$modal.msgSuccess("新增成功");
            open.value = false;
            getList();
          });
        }
        // if (form.value.type === "1") {
        //   addCalendar({
        //     ...form.value,
        //     content: {
        //       weekdays: weekDaysSettingList.value,
        //     },
        //   }).then((response) => {
        //     proxy.$modal.msgSuccess("新增成功");
        //     open.value = false;
        //     getList();
        //   });
        // } else if (form.value.type === "2") {
        addCalendar({
          ...form.value,
          content: {
            weekdays: weekDaysSettingList.value,
          },
          // holidays: holidays.value,
          applicable: applicableSettingList.value.map((item) => {
            return {
              factory: item.factory.split(";")[0],
              process: item.process.split(";")[0],
              workshop: item.workshop.split(";")[0],
            };
          }),
          applicableTranslate: JSON.stringify(
            applicableSettingList.value.map((item) => {
              return {
                factory: item.factory.split(";")[1],
                process: item.process.split(";")[1],
                workshop: item.workshop.split(";")[1],
              };
            })
          ),
          // applicableCn:
          //},
        }).then((response) => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
        });
        // }
      }
    }
  });
@@ -685,18 +1044,14 @@
  );
}
function handleSwitchType(e) {
  console.log(e, "日期类型切换");
  typeRadioNumber.value = e;
  form.value.type = e;
  form.value.effectiveDate = null;
  form.value.expiringDate = null;
  form.value.content = null;
  form.value.applicableFactory = null;
  form.value.applicableWorkshop = null;
  form.value.applicableProcess = null;
}
// 设置周工作日
function handleSetWorkDays(e) {
  console.log(weekDaysSettingList.value, "设置周工作日");
}
function changePageNo(currentPage) {
  queryParams.value.pageNum = currentPage;
@@ -709,13 +1064,12 @@
  queryParams.value.pageSize = pageSize;
  getList();
}
// function formatType(type) {
//   if(type===1){
//     return "周工作"
//   }else{
//     return "节假日"
//   }
// }
// 多选框选中数据
const handleCheckboxChange = (data) => {
  ids.value = data.records.map((item) => item.id);
  single.value = data.records.length !== 1;
  multiple.value = !data.records.length;
};
onMounted(() => {
  getList();
});
@@ -766,4 +1120,79 @@
.factory_use_item {
  margin-top: 10px;
}
.select_factory {
  font-weight: 800;
  font-size: 14px;
  color: #606266;
}
.select_factory_dis {
  margin-left: 34px;
}
.select_content {
  margin-right: 10px;
  margin-top: 20px;
  // &:nth-child(1) {
  //   margin-left:34px;
  // }
}
.mart5 {
  margin-top: 5px;
}
.custom-height {
  height: 200px; /* 或者使用 min-height */
}
.auto-height-grid .xe-body .xe-body--row {
  height: auto; /* 或者使用 min-height */
}
.mart10 {
  margin-top: 20px;
}
.h300 {
}
.height_dialog{
  height: 400px;
  overflow: hidden;
  .height_dialog_scroll{
    height: 100%;
    overflow: auto;
  }
}
.grey_bg {
  background: #f1f1f1;
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  .flex_item {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-top: 10px;
    .flex_item_dis {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: flex-start;
      & div {
        margin-bottom: 5px;
      }
    }
  }
  .flex_item_expand_end {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    cursor: pointer;
  }
}
.title_flex {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  .holiday_title {
    font-size: 15px;
    font-weight: 500;
  }
}
</style>