<template>
  <basicLayout
    ref="basicLayout"
    :oldFormPath="{
      add: 'optionSystem/executeManage/modules',
    }"
    tableName="executeTable"
    idName="itemid"
    ownertable="plm_item"
    :apiId="{ query: 2024060514063602, del: 2024060514040602 }"
    :detailPath="{
      path: '/executeDetail',
    }"
    :isExport="false"
  >
    <template #titleRight>
      <ImportFile
        :templateParam="{ id: 20240618111502, content: {} }"
        title="执行器"
        @onSuccess="bindImport"
        :errorUrl="errorUrl"
        @clearUrl="errorUrl = null"
        v-if="tool.checkAuth($route.name,'importFile')"
      ></ImportFile>
    </template>
    <template #custom>
      <div class="mt-10">
        <label class="search__label">创建时间:</label>
        <el-date-picker
          style="margin-right: 24px !important"
          size="small"
          @change="selectTimeChange"
          value-format="yyyy-MM-dd"
          v-model="dateSelect"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          clearable
        >
        </el-date-picker>
      </div>
      <div class="mt-10">
        <label class="search__label">状态:</label>
        <el-select
          class="inline-24"
          v-model="selectParam.status"
          placeholder="请选择状态"
          @change="selectStatusChange"
          size="small"
          clearable
        >
          <el-option label="新建" value="新建"></el-option>
          <el-option label="审核" value="审核"></el-option>
        </el-select>
      </div>
    </template>
    <template v-slot:tbList="scope">
      <div
        :style="
          scope.data.column.data.status === '审核'
            ? 'color:#52C41A'
            : 'color:000000'
        "
        v-if="scope.data.column.columnname === 'status'"
      >
        {{ scope.data.column.data.status }}
      </div>
      <div v-else-if="scope.data.column.columnname === 'flh'">
        {{ scope.data.column.data.flh.join(',') }}
      </div>
      <div v-else-if="scope.data.column.columnname === 'marketprice'">
        {{ tool.formatAmount(scope.data.column.data.marketprice, 2) }}
      </div>
      <div v-else>{{ scope.data.column.data[[scope.data.column.columnname]] }}</div>
    </template>
    <!-- <template v-slot:tbOpreation="scope">
       <editTemp :data="scope.data.data"></editTemp>
      </template> -->
  </basicLayout>
</template>

<script>
import ImportFile from "../modules/importFile.vue";
export default {
  components: { ImportFile },
  data() {
    return {
      selectParam: {
        status: "",
      },
      dateSelect: "",
      bodystructure: [],
      actuatordrivetype:[],
      actuatortype:[],
      func: [],
      errorUrl: null,
    };
  },
  provide() {
    return {
      bodystructure: () => {
        return this.bodystructure;
      },
      actuatordrivetype: () => {
        return this.actuatordrivetype;
      },
      actuatortype: () => {
        return this.actuatortype;
      },
      func: () => {
        return this.func;
      },
    };
  },
  methods: {
    async bindImport(id) {
      const res = await this.$api.requested({
        id: 20240618133002,
        content: {
          attachmentid: id[0],
        },
      });
      if (res.data !== "成功") {
        this.errorUrl = res.data;
      } else {
        this.tool.showMessage(res, () => {
          this.$refs.basicLayout.listData();
        });
      }
    },
    selectStatusChange() {
      this.$refs["basicLayout"].param.content.where = this.selectParam;
      this.$refs["basicLayout"].param.content.pageNumber = 1;
      this.$refs["basicLayout"].listData();
    },
    selectTimeChange() {
      if (this.dateSelect !== "" && this.dateSelect !== null) {
        this.selectParam.begindate = this.dateSelect[0];
        this.selectParam.enddate = this.dateSelect[1];
      } else {
        this.selectParam.begindate = "";
        this.selectParam.enddate = "";
      }
      this.$refs.basicLayout.param.content.pageNumber = 1;
      this.$refs.basicLayout.param.content.where = this.selectParam;
      this.$refs.basicLayout.listData();
    },
    optionList() {
      this.$store.dispatch("optiontypeselect", "bodystructure").then((res) => {
        this.bodystructure = res.data;
        console.log(this.bodystructure, "结构");
      });
      this.$store.dispatch("optiontypeselect", "func").then((res) => {
        this.func = res.data;
        console.log(this.func, "功能");
      });
      this.$store.dispatch("optiontypeselect", "lectotypetype").then((res) => {
        this.actuatortype = res.data;
        console.log(this.actuatortype, "执行器类型");
      });
      this.$store.dispatch("optiontypeselect", "actuatordrivetype").then((res) => {
        this.actuatordrivetype = res.data;
        console.log(this.actuatordrivetype, "执行器驱动类型");
      });
    },
  },
  created() {
    this.optionList();
  },
};
</script>

<style scoped>
</style>