<template>
  <div class="index_box">
    <div class="c_header_title">
      <!-- <el-tabs type="card" v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="委外记录" name="1"></el-tab-pane>
        <el-tab-pane label="请托记录" name="2"></el-tab-pane>
      </el-tabs> -->
      <div class="c_title">{{
        activeName == '1' ? '委外记录' : '请托记录'
      }}</div>
    </div>
    <div style="overflow: auto" v-if="activeName == '1'">
      <el-form
        label-width="100px"
        :rules="rules"
        ref="form"
        :model="attributeData"
      >
        <el-form-item label="委外名称:" prop="name">
          <el-input
            placeholder=""
            v-model="attributeData.name"
            style="width: 260px"
          ></el-input>
        </el-form-item>

        <el-form-item label="委外类型:" prop="type">
          <el-select
            v-model="attributeData.type"
            placeholder="请选择"
            style="width: 260px"
          >
            <el-option
              v-for="item in typeList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="委外数量:" prop="formedNumLast">
          <el-input
            placeholder="请输入委外数量"
            type="number"
            v-model="attributeData.formedNumLast"
            style="width: 260px"
          ></el-input>
        </el-form-item>
        <el-form-item label="委外工序:" prop="taskIdes">
          <el-select
            v-model="attributeData.taskIdes"
            placeholder="请选择"
            style="width: 260px"
            @change="changeTaskId"
            multiple
          >
            <el-option
              v-for="item in newStepsList"
              :key="item.taskId"
              :label="item.taskTypeName"
              :value="item.taskId"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="委外场景:" prop="sceneText">
          <el-input
            placeholder=""
            v-model="attributeData.sceneText"
            disabled
            style="width: 260px"
          ></el-input>
        </el-form-item>
        <el-form-item label="直接入库:" borderBottom prop="warehouseId">
          <div style="display: flex">
            <div
              style="font-size: 15px"
              v-if="attributeData.clientEnvironmentId == 2"
              >是</div
            >
            <el-select
              v-if="attributeData.clientEnvironmentId == 2 || isInWarehouse"
              v-model="attributeData.warehouseId"
              placeholder="请选择"
              style="width: 260px"
            >
              <el-option
                v-for="item in warehouseList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </div>
        </el-form-item>

        <el-form-item label="交付类型:" prop="deliveryMethod">
          <el-select
            v-model="attributeData.deliveryMethod"
            placeholder="请选择"
            style="width: 260px"
          >
            <el-option
              v-for="item in deliveryMethodTypeList"
              :key="item.value"
              :label="item.name"
              :value="item.value"
            >
            </el-option>
          </el-select>

          <el-link
            type="primary"
            :underline="false"
            @click="setBatchTime"
            v-if="attributeData.deliveryMethod == 2"
            style="margin-left: 10px"
          >
            设置分批时间
          </el-link>
        </el-form-item>

        <el-form-item label="委外单位:">
          <el-select
            v-model="attributeData.supplierId"
            placeholder="请选择"
            style="width: 260px"
            @change="changeTaskId"
            filterable
          >
            <el-option
              v-for="(item, index) in gysList"
              :key="item.id + index"
              :value="item.id"
              :label="item.name"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-form-item
          label="工艺路线:"
          borderBottom
          style="font-size: 15px"
          prop="produceRoutingId"
          v-if="
            attributeData.clientEnvironmentId != 2 &&
            attributeData.isFirstTask != 1 &&
            isInWarehouse &&
            isInWarehouse.length == 0
          "
        >
          <el-select
            v-model="attributeData.produceRoutingId"
            placeholder="请选择"
            style="width: 260px"
          >
            <el-option
              v-for="item in produceList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="交付交期:" prop="requireDeliveryTime">
          <el-date-picker
            v-model="attributeData.requireDeliveryTime"
            value-format="yyyy-MM-dd HH:mm:ss"
            style="width: 260px"
            type="date"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>

        <el-form-item label="生产备注:">
          <el-input
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 4 }"
            placeholder="请输入内容"
            v-model="textarea2"
            style="width: 260px"
          >
          </el-input>
        </el-form-item>

        <div class="btn-box">
          <el-button type="primary" @click="confirm">确认</el-button>
          <el-button type="primary" @click="cancel">取消</el-button>
        </div>
      </el-form>
    </div>

    <div v-if="activeName == '2'">
      <el-form
        label-width="100px"
        :rules="rulesPlease"
        ref="form"
        :model="form"
      >
        <el-form-item label="请托名称:" prop="name">
          <el-input
            placeholder=""
            v-model="form.name"
            style="width: 260px"
          ></el-input>
        </el-form-item>

        <el-form-item label="请托类型:" prop="type">
          <DictSelection
            dictName="请托类型"
            v-model="form.type"
            style="width: 260px"
          ></DictSelection>
        </el-form-item>

        <el-form-item label="紧急程度:" prop="priority">
          <el-select
            style="width: 260px"
            v-model="form.priority"
            placeholder="请选择"
            clearable
          >
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.name"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="请托数量:" prop="totalCount">
          <el-input v-model="form.totalCount" style="width: 260px">
            <template slot="append">{{ form.measuringUnit }}</template>
          </el-input>
        </el-form-item>
        <el-form-item label="请托工序:" prop="taskId">
          <el-select
            v-model="form.taskId"
            placeholder="请选择"
            style="width: 260px"
            @change="taskListChange"
          >
            <el-option
              v-for="item in pleaseNewStepsList"
              :key="item.taskId"
              :label="item.taskTypeName"
              :value="item.taskId"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <!--
        <el-form-item label="请托人:" prop="pleaseEntrustUserId">
          <el-input
            v-model="form.pleaseEntrustUserName"
            clearable
            disabled
            style="width: 260px"
          />
        </el-form-item>

        <el-form-item label="请托部门:" prop="pleaseEntrustDeptName">
          <el-input
            v-model="form.pleaseEntrustDeptName"
            clearable
            disabled
            style="width: 260px"
          >
          </el-input>
        </el-form-item>

        <el-form-item label="所属工厂:" prop="factoriesName">
          <el-input v-model="form.factoriesName" disabled style="width: 260px">
          </el-input>
        </el-form-item> -->

        <el-form-item label="受托工厂:" prop="beEntrustedFactoriesId">
          <el-select
            style="width: 260px"
            v-model="form.beEntrustedFactoriesId"
            placeholder="请选择"
            clearable
          >
            <el-option
              v-for="item in factoryList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
              @click.native="factoryListChange(item)"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="受托部门:" prop="beEntrustedDeptId">
          <deptSelect
            style="width: 260px"
            v-model="form.beEntrustedDeptId"
            @changeGroup="beEntrustedDeptIdChange"
          />
        </el-form-item>

        <el-form-item label="完成日期:" prop="planDeliveryTime">
          <el-date-picker
            v-model="form.planDeliveryTime"
            type="datetime"
            style="width: 260px"
            placeholder="选择日期时间"
            format="yyyy-MM-dd HH:mm:ss"
            value-format="yyyy-MM-dd HH:mm:ss"
          >
          </el-date-picker>
        </el-form-item>

        <el-form-item label="是否尾工序:" prop="isLast">
          <el-radio-group v-model="form.isLast">
            <el-radio :label="1">是</el-radio>
            <el-radio :label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>

        <el-form-item label="需求描述:">
          <el-input
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 4 }"
            placeholder="请输入内容"
            v-model="form.describes"
            style="width: 260px"
          >
          </el-input>
        </el-form-item>
      </el-form>

      <div class="btn-box">
        <el-button type="primary" @click="cancel">取消</el-button>
        <el-button type="primary" @click="save(1)"> 保存 </el-button>
        <el-button type="primary" @click="save(2)"> 提交 </el-button>
      </div>
    </div>

    <timeDialog ref="timeDialogRef"></timeDialog>
  </div>
</template>

<script>
  import { getWarehouseList, producerouting } from '@/api/produce/index.js';
  import { contactList } from '@/api/produce/bom.js';
  import { getFactoryarea } from '@/api/aps';
  import timeDialog from './timeDialog.vue';
  import deptSelect from '@/components/CommomSelect/dept-select.vue';
  import { getTaskInstanceById } from '@/api/produce/index';
  import { save, addSubmit, update } from '@/api/entrust/index';
  export default {
    components: {
      timeDialog,
      deptSelect
    },
    data() {
      return {
        attributeData: {
          name: '',
          type: '', //类型
          sceneText: '', //场景
          formedNumLast: '', //数据
          taskIds: '', //委外到
          isFirstTask: '',
          clientEnvironmentId: 1, //直接入库
          requireDeliveryTime: '', //计划交期
          warehouseId: '', //仓库id
          produceRoutingId: '', //工艺路线id
          supplierId: '', //供应商id
          supplierName: '',
          taskIdes: [],
          factoriesId: '',
          factoriesName: '',
          taskDataList: [],
          priority: '',
          deliveryMethod: 1,
          timeList: []
        },
        isInWarehouse: true,
        produceList: [],
        warehouseList: [],
        newStepsList: [],
        taskIds: '',
        typeList: [
          {
            id: 4,
            name: '带料生产委外'
          },
          {
            id: 5,
            name: '不带料生产委外'
          }
        ],

        deliveryMethodTypeList: [
          {
            name: '一次性到货',
            value: 1
          },
          {
            name: '分批到货',
            value: 2
          }
        ],

        options: [
          {
            name: '一般',
            value: 1
          },
          {
            name: '紧急',
            value: 2
          }
        ],

        rules: {
          name: [
            { required: true, message: '请输入委外名称', trigger: 'blur' }
          ],
          type: [
            { required: true, message: '请选择委外类型', trigger: 'blur' }
          ],
          formedNumLast: [
            { required: true, message: '请输入委外数量', trigger: 'blur' }
          ],
          taskIdes: [
            { required: true, message: '请选择委外工序', trigger: 'blur' }
          ],
          sceneText: [
            { required: true, message: '请选择委外场景', trigger: 'blur' }
          ],
          warehouseId: [{ required: true, message: '请选择', trigger: 'blur' }],
          requireDeliveryTime: [
            { required: true, message: '请选择计划交期时间', trigger: 'blur' }
          ]
        },

        rulesPlease: {
          type: [{ required: true, message: '请选择', trigger: 'change' }],
          name: [{ required: true, message: '请输入', trigger: 'change' }],

          workOrderCode: [
            { required: true, message: '请选择', trigger: 'change' }
          ],
          beEntrustedDeptId: [
            { required: true, message: '请选择', trigger: 'change' }
          ],
          finishTime: [
            { required: true, message: '请选择', trigger: 'change' }
          ],
          beEntrustedFactoriesId: [
            { required: true, message: '请选择', trigger: 'change' }
          ],
          isLast: [{ required: true, message: '请选择', trigger: 'change' }],
          planDeliveryTime: [
            { required: true, message: '请选择', trigger: 'change' }
          ],
          totalCount: [
            { required: true, message: '请输入', trigger: 'change' }
          ],
          taskId: [{ required: true, message: '请选择', trigger: 'change' }]
        },

        form: {
          type: '',
          priority: '',
          name: '',
          pleaseEntrustDeptName: '',
          pleaseEntrustUserName: '',
          factoriesName: '',
          beEntrustedFactoriesId: '',
          beEntrustedDeptId: '',
          isLast: 0,
          describes: '',
          taskId: '',
          planDeliveryTime: '',
          beEntrustedDeptName: '',
          beEntrustedFactoriesName: '',
          pleaseEntrustDeptId: '',
          pleaseEntrustUserId: '',
          factoriesId: '',
          factoriesName: '',
          status: '',
          approvalStatus: ''
        },

        loading: false,
        operationType: null,
        activeName: this.chooseType,
        textarea2: '',
        gysList: [],
        factoryList: [],
        pleaseNewStepsList: [],
        clientEnvironmentId: this.$store.state.user.info.clientEnvironmentId
      };
    },
    props: {
      outsourceFormVal: {
        type: Object,
        default: () => ({})
      },
      taskObj: {
        type: Object,
        default: ''
      },
      chooseType: {
        type: String,
        default: '1'
      },
      workListIds: {
        type: String,
        default: ''
      },
      workData: {
        type: Object,
        default: () => ({})
      }
    },

    watch: {
      outsourceFormVal: {
        handler(val) {
          console.log(val, 'outsourceForm');
          Object.assign(this.attributeData, val);

          // console.log(this.attributeData.newStepsList, 'attributeData');

          // this.newStepsList = this.attributeData.newStepsList.filter(
          //   (item) => item.type != 2 && item.type != 3 && item.type != 6
          // );

          if (this.clientEnvironmentId == 3) {
            if (
              this.attributeData.newStepsList &&
              this.attributeData.newStepsList.length != 0
            ) {
              this.newStepsList = this.attributeData.newStepsList.filter(
                (item) => item.type != 6
              );
            }
          } else {
            this.newStepsList = this.attributeData.newStepsList;
          }

          this.getWarehouseFn();
          this.produceFn();
        },
        deep: true,
        immediate: true
      }
    },
    // computed: {
    //   taskObj() {
    //     return this.$store.state.user.taskObj;
    //   }
    // },

    mounted() {
      this.getContactList();
      this.getFactoryList();
      if (this.chooseType == '1') {
        this.attributeData.name = this.taskObj.name
          ? this.taskObj.name + '委外'
          : this.taskObj.taskTypeName + '委外';
      } else if (this.chooseType == '2') {
        this.attributeData.name = this.taskObj.taskName + '请托';
      }

      // if (this.chooseType == '2') {
      //   this.form.pleaseEntrustDeptName = this.$store.state.user.info.groupName;
      //   this.form.pleaseEntrustDeptId = this.$store.state.user.info.groupId;
      //   this.form.pleaseEntrustUserName = this.$store.state.user.info.name;
      //   this.form.pleaseEntrustUserId = this.$store.state.user.info.userId;
      //   const newList = this.workData.list.map((item) => {
      //     const copy = this.deepCopy(item);

      //     Object.assign(copy, {
      //       describes: '',
      //       totalCount: copy.formingNum,
      //       taskList: [],
      //       beEntrustedFactoriesId: '',
      //       beEntrustedFactoriesName: '',
      //       status: '',
      //       beEntrustedDeptName: '',
      //       beEntrustedDeptId: '',
      //       measuringUnit: copy.unit,
      //       categoryName: copy.productName,
      //       categoryCode: copy.productCode,
      //       workOrderId: copy.id,
      //       workOrderCode: copy.code,
      //       brandNum: copy.brandNo,
      //       modelType: copy.model,
      //       name: '',
      //       type: '',
      //       planDeliveryTime: copy.startTime,
      //       applyDeptId: this.form.pleaseEntrustDeptId,
      //       applyDeptName: this.form.pleaseEntrustDeptName,
      //       applyFactoriesId: this.form.factoriesId,
      //       applyFactoriesName: this.form.factoriesName
      //     });

      //     return copy;
      //   });

      //   const data = Object.assign(this.form, newList[0]);
      //   this.form = this.deepCopy(data);
      //   console.log(this.taskObj, '工单数据');
      //   this.form.name = this.taskObj.name
      //     ? this.taskObj.name + '请托'
      //     : this.taskObj.taskTypeName + '请托';

      //   this.getTaskInstanceByIdFn(this.workListIds);
      // }

      if (this.chooseType === '2') {
        const userInfo = this.$store.state.user.info;

        Object.assign(this.form, {
          pleaseEntrustDeptName: userInfo.groupName,
          pleaseEntrustDeptId: userInfo.groupId,
          pleaseEntrustUserName: userInfo.name,
          pleaseEntrustUserId: userInfo.userId
        });

        console.log(this.workData.list, 'form数据');

        const newList = this.workData.list.map((item) => {
          const copy = this.deepCopy(item);

          const commonData = {
            describes: '',
            totalCount: copy.formingNum,
            taskList: [],
            beEntrustedFactoriesId: '',
            beEntrustedFactoriesName: '',
            status: '',
            beEntrustedDeptName: '',
            beEntrustedDeptId: '',
            measuringUnit: copy.unit,
            categoryName: copy.productName,
            categoryCode: copy.productCode,
            workOrderId: copy.id,
            workOrderCode: copy.code,
            brandNum: copy.brandNo,
            modelType: copy.model,
            name: '',
            type: '',
            planDeliveryTime: copy.startTime,
            applyDeptId: this.form.pleaseEntrustDeptId,
            applyDeptName: this.form.pleaseEntrustDeptName,
            applyFactoriesId: this.form.factoriesId,
            applyFactoriesName: this.form.factoriesName
          };

          return Object.assign(copy, commonData);
        });

        this.form = this.deepCopy({
          ...this.form,
          ...newList[0]
        });

        console.log(this.form, '最终form数据');

        this.form.name = this.taskObj.name
          ? `${this.taskObj.name}请托`
          : `${this.taskObj.taskTypeName}请托`;

        this.getTaskInstanceByIdFn(this.workListIds);
      }
    },

    methods: {
      // 工艺路线
      produceFn() {
        let param = {
          pageNum: 1,
          size: -1,
          routeType: 2
        };
        producerouting(param).then((res) => {
          this.produceList = res.list;
        });
      },

      async getTaskInstanceByIdFn(workOrderId, taskId) {
        await getTaskInstanceById(workOrderId).then((res) => {
          let { data } = res;
          if (data.length) {
            data = data.filter((item) => item.taskId != -2);
            let arr = data.findIndex((item) =>
              item.name ? item.sourceTaskId : item.taskId == this.form.taskId
            );

            if (arr != -1) {
              data.splice(0, arr);
            }

            this.pleaseNewStepsList = data;
          }
        });
      },

      async getFactoryList() {
        let par = {
          type: 1,
          size: 9999
        };
        await getFactoryarea(par).then((res) => {
          console.log(res, '工厂数据');
          if (res.list && res.list.length > 0) {
            console.log(res.list, '工厂数据');
            this.factoryList = res.list;
            // this.factoryList = res.list.map((el) => {
            //   return {
            //     value: el.factoryId,
            //     label: el.factoryName
            //   };
            // });
          }
          const data = this.factoryList.filter(
            (it) => it.factoryId == this.$store.state.user.info.factoryId
          );

          if (data.length != 0) {
            this.form.factoriesId = data[0].factoryId;
            this.form.factoriesName = data[0].factoryName;
          }
        });
        console.log(this.factoryList, '工厂数据111');
      },

      beEntrustedDeptIdChange(val, row) {
        this.form.beEntrustedDeptName = row.name;
      },
      factoryListChange(row) {
        this.form.beEntrustedFactoriesName = row.name;
      },

      deepCopy(obj, hash = new WeakMap()) {
        if (obj === null) return null;
        if (obj instanceof Date) return new Date(obj);
        if (obj instanceof RegExp) return new RegExp(obj);
        if (typeof obj !== 'object' && typeof obj !== 'function') return obj;
        if (hash.has(obj)) return hash.get(obj);

        const result = Array.isArray(obj) ? [] : {};
        hash.set(obj, result);

        return Object.keys(obj).reduce((acc, key) => {
          acc[key] = this.deepCopy(obj[key], hash);
          return acc;
        }, result);
      },

      async getContactList() {
        let param = {
          pageNum: 1,
          type: 2,
          size: -1,
          status: 1
        };
        await contactList(param).then((res) => {
          this.gysList = res.list;
        });
        console.log(this.gysList, '供应商数据');
      },

      setBatchTime() {
        this.$refs.timeDialogRef.open(this.attributeData, null, false);
      },

      // handleClick(tab, event) {
      //   this.activeName = tab._props.name;
      //   if (this.activeName == '1') {
      //     this.resetData();
      //     this.attributeData.name = this.taskName + '委托';
      //   } else if (this.activeName == '2') {
      //     this.resetData();
      //     this.attributeData.name = this.taskName + '请托';
      //   }
      // },

      // 仓库
      getWarehouseFn() {
        getWarehouseList().then((res) => {
          // console.log(
          //   this.$store.state.user.info.factoryId,
          //   'this.$store.state.user.info'
          // );
          // console.log(res, '仓库数据');
          this.warehouseList = res.data.filter(
            (item) => item.factoryId == this.$store.state.user.info.factoryId
          );
          // console.log(this.warehouseList, '数据');
          // console.log(res, '仓库数据');
          // this.warehouseList = res.data;
        });
      },

      changeDelivery(e) {},

      batchDeliveryTime() {
        this.$refs.timeDialogRef.open(this.attributeData, null, false);
      },

      taskListChange() {
        const data = this.pleaseNewStepsList.filter(
          (it) => it.taskId == this.form.taskId
        );

        this.form.taskName = data[0].taskTypeName;
      },

      changeTaskId(e) {
        console.log(e);
        const arr = this.newStepsList.find((item) => item.taskId === e);

        if (this.attributeData.taskIdes.length != 0) {
          if (this.attributeData.taskIdes.length == 1) {
            this.attributeData.sceneText = '单工序';
            this.attributeData.outsourceScene = 2;
          } else {
            this.attributeData.sceneText = '多工序';
            this.attributeData.outsourceScene = 3;
          }
          // const id = this.newStepsList[0].sourceTaskId;
          // if (this.attributeData.isFirstTask) {
          //   this.attributeData.sceneText = '首工序';
          //   this.attributeData.outsourceScene = 1;
          //   if (arr.sourceTaskId !== id) {
          //     this.attributeData.sceneText = '首工序及多工序';
          //     this.attributeData.outsourceScene = 4;
          //   }
          // } else {
          //   if (arr.sourceTaskId === id) {
          //     // 单工序
          //     this.attributeData.sceneText = '单工序';
          //     this.attributeData.outsourceScene = 2;
          //   } else {
          //     //多工序
          //     this.attributeData.sceneText = '多工序';
          //     this.attributeData.outsourceScene = 3;
          //   }
          // }
        } else {
          this.attributeData.sceneText = '';
          this.attributeData.outsourceScene = '';
          // uni.showToast({
          //   title: '委外到工序为空',
          //   icon: 'none'
          // });
        }
      },

      resetData() {
        this.attributeData.type = '';
        this.attributeData.sceneText = '';
        this.attributeData.taskIds = '';
        this.attributeData.isFirstTask = '';
        this.attributeData.clientEnvironmentId = 1;
        this.attributeData.requireDeliveryTime = '';
        this.attributeData.warehouseId = '';
        this.attributeData.produceRoutingId = '';
        this.attributeData.supplierId = '';
        this.attributeData.taskIdes = [];
        this.attributeData.factoriesId = '';
        this.attributeData.taskDataList = [];
        this.attributeData.priority = '';
      },

      //跳转

      confirm() {
        this.$refs.form.validate((valid) => {
          if (valid) {
            if (this.activeName == '1') {
              if (this.attributeData.supplierId) {
                const obj = this.gysList.find(
                  (item) => item.id === this.attributeData.supplierId
                );
                this.attributeData.supplierName = obj ? obj.name : '';
              }

              this.attributeData.taskIdes.forEach((it) => {
                this.newStepsList.filter((i) => {
                  if (i.taskId == it) {
                    this.attributeData.taskDataList.push(i);
                  }
                });
              });
              this.attributeData.taskIds =
                this.attributeData.taskIdes.join(',');
              this.$emit('changePlugIn', this.attributeData, this.activeName);
            }
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },

      save(type) {
        this.$refs.form.validate((valid) => {
          if (!valid) {
            return false;
          }

          let URL;

          const clearOrderIds = () => {
            this.form.id = '';
          };

          if (type === 1) {
            // 新增
            URL = save;
            clearOrderIds();
          } else {
            // 其他类型提交
            URL = addSubmit;
            clearOrderIds();
          }

          this.loading = this.$loading({
            lock: true,
            text: '加载中',
            background: 'rgba(0, 0, 0, 0.7)'
          });

          this.form.status = type == 1 ? 0 : 1;
          this.form.approvalStatus = type == 1 ? 0 : 1;

          const list = [];
          list.push(this.form);

          console.log(this.form, '最终form数据111111');

          URL(list)
            .then((res) => {
              this.loading.close();
              this.$message.success('成功');
              this.cancel();
            })
            .catch((e) => {
              this.loading.close();
            });
        });
      },
      cancel() {
        this.$emit('changeCancel', this.activeName);
      }
    },
    created() {
      this.operationType = null;
    }
  };
</script>

<style scoped>
  .index_box {
    padding: 0 !important;
    overflow: auto;
  }

  .c_header_title {
    display: flex;
    align-items: center;
    margin-bottom: 0;
    padding-left: 20px;
    height: 52px;
    margin-bottom: 10px;
    box-sizing: border-box;
    background: var(--table-header-background-color);
    border-bottom: 1px solid var(--border-color-lighter);
  }

  .c_title {
    color: #157a2c;
    font-size: 16px;
    font-weight: bold;
  }

  .btn-box {
    margin-left: 50px;
  }

  ::v-deep .el-select__tags {
    flex-wrap: nowrap;
    overflow: auto;
  }

  /* 输入框最大宽度*/
  ::v-deep .el-select__tags-text {
    max-width: 90px;
  }

  /* 底部滚动条的高度*/
  ::v-deep .el-select__tags::-webkit-scrollbar {
    height: 2px !important;
  }

  ::v-deep .el-form-item {
    margin-bottom: 13px !important;
  }

  ::v-deep .ele-basic-select {
    width: 260px !important;
  }
</style>
