zhaojiale
2022-08-04 2e52dcb4fb8766d7d9c0034b7bba3e1d02e24906
src/views/goalManagement/targetDecompositionYear/component/Dailog.vue
@@ -6,8 +6,10 @@
            <el-col :span="11">
               <el-form-item label="安全目标指标" size="default">
                  <el-input v-model="form.qName" :disabled="disabled">
                     <template #append> <el-button :icon="Search" @click="daiInpt" /> </template
                  ></el-input>
                     <template #append>
                        <el-button :icon="Search" @click="daiInpt" />
                     </template>
                  </el-input>
               </el-form-item>
            </el-col>
            <el-col :span="11" :offset="2">
@@ -34,17 +36,17 @@
            <el-button type="primary" size="default" @click="daiAdd" :disabled="disabled">新增</el-button>
         </el-tab-pane>
      </el-tabs>
      <el-table :data="tableData" style="width: 100%">
         <el-table-column align="center" prop="dutyDepartmentId" label="责任部门" width="180" />
         <el-table-column align="center" prop="value" label="考核指标" width="180" />
         <el-table-column align="center" prop="makerDepartmentId" label="制定人部门" />
         <el-table-column align="center" prop="makeDate" label="制定日期" />
         <el-table-column align="center" prop="commitPersonId" label="上报人" />
         <el-table-column align="center" label="操作">
            <template #default>
               <el-button link type="primary">查看</el-button>
               <el-button link :disabled="disabled" type="primary">修改</el-button>
               <el-button link :disabled="disabled" type="primary">删除</el-button>
      <el-table :data="formUp.targetDivideDetailList" style="width: 100%">
         <el-table-column align="center" property="dutyDepartmentId" label="责任部门" width="180" />
         <el-table-column align="center" property="value" label="考核指标" width="180" />
         <el-table-column align="center" property="makerDepartmentId" label="制定人部门" />
         <el-table-column align="center" property="makeDate" :formatter="timeDate(makeDate)" label="制定日期" />
         <el-table-column align="center" property="commitPersonId" label="上报人" />
         <el-table-column align="center" property="操作">
            <template #default="scope">
               <el-button link type="primary" @click="daiAdd('查看', scope.row)">查看</el-button>
               <el-button link :disabled="disabled" type="primary" @click="daiAdd('修改', scope.row)">修改</el-button>
               <el-button link :disabled="disabled" type="primary" @click="Delete(scope.row)">删除</el-button>
            </template>
         </el-table-column>
      </el-table>
@@ -65,11 +67,18 @@
import { ElMessageBox, ElMessage, ElButton, ElInput, TabsPaneContext } from 'element-plus';
import DailogSearch from '../../../../components/DailogSearch/DailogSearch.vue';
import { goalManagementApi } from '/@/api/goalManagement';
import { emit } from 'process';
export default defineComponent({
   components: { DailogAdd, DailogSearch },
   setup() {
   setup(props,{emit}) {
      const dialogVisible = ref<boolean>(false);
      const form = ref({});
      const form = ref({
         qName: '',
         indexNum: '',
         year: '',
         value: '',
         targetDivideDetailList:[]
      });
      const targetType = ref();
      const disabled = ref(false);
      const titles = ref();
@@ -84,14 +93,15 @@
               .then((res) => {
                  if (res.data.code == 200) {
                     form.value = res.data.data;
                     formUp.targetDivideDetailList=form.value.targetDivideDetailList
                  } else {
                     ElMessage.error(res.data.msg);
                  }
               });
         }
      };
      const onNumber = (e: object) => {
         form.value = e;
      const onNumber = (val: object) => {
         form.value = val;
      };
      // 导航
      const activeName = ref('1');
@@ -99,27 +109,56 @@
      const tableData = ref([]);
      // 新增弹窗
      const Show = ref();
      const daiAdd = () => {
         Show.value.openDailog();
      const daiAdd = (title: string, data: any) => {
         console.log(data);
         Show.value.openDailog(title, data);
      };
      const formUp = reactive({
         targetId:"", //关联的目标指标/外键
         targetId: '', //关联的目标指标/外键
         delTargetDivideDetails: '', //要删除的目标指标分解ID,多个用逗号隔开
         targetDivideDetailList: [], //目标指标分解列表
      });
      const add = (e:any) => {
         formUp.targetDivideDetailList.push(e)
      const add = (val: any) => {
         formUp.targetDivideDetailList.push(val);
         // let obj=JSON.parse(JSON.stringify(form.value))
         formUp.targetId=form.value.id
         goalManagementApi().gettargetDivideDetail(formUp).then(res=>{
            if(res.data.code==200){
            }
         })
      };
      const submitForm=()=>{
      }
      // 新增
      const submitForm = () => {
         formUp.delTargetDivideDetails=arr.value.toString()
         formUp.targetId = form.value.id;
         goalManagementApi()
            .gettargetDivideDetail(formUp)
            .then((res) => {
               if (res.data.code == 200) {
                  ElMessage({
                     message: res.data.msg,
                     type: 'success',
                  });
                  dialogVisible.value = false;
                  emit("addList")
               } else {
                  ElMessage.error(res.data.msg);
               }
            });
            form.value = {
            qName: '',
            indexNum: '',
            year: '',
            value: '',
            targetDivideDetailList:[]
         };
         tableData.value = [];
         formUp.targetId = '';
         formUp.delTargetDivideDetails = '';
         formUp.targetDivideDetailList = [];
      };
      const arr=ref([])
      // 删除
      const Delete = (data: any) => {
         formUp.targetDivideDetailList.splice(form.value.targetDivideDetailList.indexOf(data), 1);
         formUp.targetId = data.targetId;
         arr.value.push(data.id)
      };
      // 安全目标指标弹窗
      const Shows = ref();
      const daiInpt = () => {
@@ -128,8 +167,17 @@
      // 关闭
      const resetForm = () => {
         dialogVisible.value = false;
         form.value = {};
         form.value = {
            qName: '',
            indexNum: '',
            year: '',
            value: '',
            targetDivideDetailList:[]
         };
         tableData.value = [];
         formUp.targetId = '';
         formUp.delTargetDivideDetails = '';
         formUp.targetDivideDetailList = [];
      };
      //全屏
      const full = ref(false);
@@ -140,7 +188,15 @@
            full.value = false;
         }
      };
      // 时间格式处理
      const timeDate = (data: any) => {
         console.log('xxxxxxxxxxx',data)
         let result = new Date(data).getTime();
         return result;
      };
      return {
         arr,
         timeDate,
         form,
         dialogVisible,
         openDailog,
@@ -161,7 +217,8 @@
         titles,
         add,
         formUp,
         submitForm
         submitForm,
         Delete,
      };
   },
});