Newer
Older
KaiFengPC / src / views / floodSys / scada / plcDatasource / tableDalgo.vue
@zhangdeliang zhangdeliang on 23 May 4 KB 初始化项目
<template>
  <div class="water-analysis-page">
    <div class="top">
      <el-form label-width="auto" :rules="plcDatasourceRules" inline ref="ruleForm" :model="FormList" :disabled="typeList.types == 1">
        <el-form-item
          :label="i.label"
          :style="{ width: i.prop == 'fileList1' ? '93%' : '45%' }"
          :prop="i.prop"
          v-for="i in plcDatasourceForm"
          :disabled="typeList.types == 1 || typeList.types == 2"
        >
          <el-input v-model="FormList.address" v-if="i.prop == 'address'" @click="clickMap(2)" :placeholder="i.placeholder"> </el-input>
          <el-radio-group v-model="FormList.status" v-else-if="i.prop == 'status'">
            <el-radio style="margin-top: -5px" label="1" size="large">启用</el-radio>
            <el-radio style="margin-top: -5px" label="0" size="large">停用</el-radio>
          </el-radio-group>

          <el-select
            style="width: 100%"
            clearable
            v-model="FormList.type"
            class="m-2"
            v-else-if="i.prop == 'type'"
            :placeholder="i.placeholder"
          >
            <el-option v-for="dict in plcDatasource_source" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>

          <el-select
            style="width: 100%"
            clearable
            v-model="FormList.reportType"
            class="m-2"
            v-else-if="i.prop == 'reportType'"
            :placeholder="i.placeholder"
          >
            <el-option v-for="dict in reportType_source" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>

          <el-select
            style="width: 100%"
            clearable
            v-model="FormList.dataType"
            class="m-2"
            v-else-if="i.prop == 'dataType'"
            :placeholder="i.placeholder"
          >
            <el-option v-for="dict in dataType_source" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>

          <el-input
            v-else
            v-model="FormList[i.prop]"
            :placeholder="i.placeholder"
            :disabled="i.prop == 'projectNo'"
            :type="i.prop == 'property' || i.prop == 'remark' ? 'textarea' : ''"
          >
          </el-input>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script setup>
import { projectInfoAdd, projectInfoEdit } from '@/api/scada/plcDatasource';
import { plcDatasourceRules } from '@/utils/rules';
import { plcDatasourceForm, plcDatasource_source, reportType_source, dataType_source } from '@/utils/form';
const { proxy } = getCurrentInstance();
const { typeList } = defineProps(['typeList']);
const emits = defineEmits();
defineExpose({ submit, closed, resetFiled });
let FormList = ref({ projectNo: '', fileSaveRequestList: [], status: '0' });
const fileList1 = ref([]);
function submit() {
  proxy.$refs.ruleForm.validate(valid => {
    if (valid) {
      FormList.value.fileSaveRequestList = [];
      if (typeList.types == 4) {
        projectInfoAdd(FormList.value).then(({ code }) => {
          if (code == 200) {
            proxy.$modal.msgSuccess('新增成功');
            emits('onModalClose');
          }
        });
      } else {
        projectInfoEdit(FormList.value).then(({ code }) => {
          if (code == 200) {
            proxy.$modal.msgSuccess('修改成功');
            emits('onModalClose');
          }
        });
      }
    }
  });
}
// function loadProjerctListData() {
//   projectInfoList().then(response => {
//     ProjectListData.value = response.data;
//     FormList.value = typeList;
//     fileList1.value = typeList.fileList1;
//     proxy.$refs.ruleForm.resetFields();
//   });
// }
function resetFiled() {
  proxy.$refs.ruleForm.resetFields();
  fileList1.value = [];
}

function closed() {
  emits('onModalClose');
}
const isMap = ref(false);
function clickMap(v) {
  isMap.value = true;
}
onMounted(() => {
  FormList.value = typeList;
  // loadProjerctListData();
});
</script>
<style lang="scss" scoped>
.water-analysis-page {
  padding: 20px;
}
</style>