<template>
  <div>
    <div class="text-lg mb-4">档案模板设置：</div>
    <div>
      <el-select v-model="detail.formTemplateId">
        <el-option v-for="(item, index) in templateList" :key="index" :label="item.name" :value="item.id"></el-option>
      </el-select>
      <el-button type="primary" class="ml-4" @click="saveTemplateSetting">保存</el-button>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { request } from "@/utils";
import { ElMessage } from "element-plus";

const detail = ref({
  createdAt: "2",
  formTemplateId: "",
  id: "",
  mechanism: null,
  permissions: "",
  status: 0,
  updatedAt: ""
});
const templateList = ref([])
const getTemplates = async () => {
  const { data } = await request.get(`/archivesService/mechanism/formTemplate/list`)
  templateList.value = data.list
};
getTemplates()
const getDetail = async () => {
  const { data } = await request.get(
    "/archivesService/mechanism/mechanismConfig/detail"
  );
  detail.value = data.detail
};
getDetail();
const saveTemplateSetting = async () => {
  await request.post(
    "/archivesService/mechanism/mechanismConfig/setFormTemplate", {
      formTemplateId: detail.value.formTemplateId
    }
  );
  ElMessage.success('操作成功')
  getDetail()
};
</script>

<style lang="scss" scoped></style>
