horse soft 基础框架前端界面
autumnal_wind@yeah.net
2024-05-24 15bfb77bbce8190992271b2c0ff2ea8ab2ba7996
src/views/basis/sysParam/config/index.vue
@@ -38,7 +38,7 @@
      <template #header>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:config:add']">新增</el-button>
            <el-button type="primary" plain icon="Plus" @click="openForm('create')" v-hasPermi="['system:config:add']">新增</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:config:edit']">
@@ -92,39 +92,41 @@
    </el-card>
    <!-- 添加或修改参数配置对话框 -->
    <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
      <el-form ref="configFormRef" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="参数名称" prop="configName">
          <el-input v-model="form.configName" placeholder="请输入参数名称" />
        </el-form-item>
        <el-form-item label="参数键名" prop="configKey">
          <el-input v-model="form.configKey" placeholder="请输入参数键名" />
        </el-form-item>
        <el-form-item label="参数键值" prop="configValue">
          <el-input v-model="form.configValue" placeholder="请输入参数键值" />
        </el-form-item>
        <el-form-item label="系统内置" prop="configType">
          <el-radio-group v-model="form.configType">
            <el-radio v-for="dict in sys_yes_no" :key="dict.value" :label="dict.value">{{ dict.label }}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
<!--    <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>-->
<!--      <el-form ref="configFormRef" :model="form" :rules="rules" label-width="80px">-->
<!--        <el-form-item label="参数名称" prop="configName">-->
<!--          <el-input v-model="form.configName" placeholder="请输入参数名称" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="参数键名" prop="configKey">-->
<!--          <el-input v-model="form.configKey" placeholder="请输入参数键名" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="参数键值" prop="configValue">-->
<!--          <el-input v-model="form.configValue" placeholder="请输入参数键值" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="系统内置" prop="configType">-->
<!--          <el-radio-group v-model="form.configType">-->
<!--            <el-radio v-for="dict in sys_yes_no" :key="dict.value" :label="dict.value">{{ dict.label }}</el-radio>-->
<!--          </el-radio-group>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="备注" prop="remark">-->
<!--          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />-->
<!--        </el-form-item>-->
<!--      </el-form>-->
<!--      <template #footer>-->
<!--        <div class="dialog-footer">-->
<!--          <el-button type="primary" @click="submitForm">确 定</el-button>-->
<!--          <el-button @click="cancel">取 消</el-button>-->
<!--        </div>-->
<!--      </template>-->
<!--    </el-dialog>-->
    <detail-form ref="detailFormRef" @success="getList"/>
  </div>
</template>
<script setup name="Config" lang="ts">
import { listConfig, getConfig, delConfig, addConfig, updateConfig, refreshCache } from "@/api/system/config";
import { ConfigForm, ConfigQuery, ConfigVO } from "@/api/system/config/types";
import DetailForm from "@/views/basis/sysParam/config/DetailForm.vue";
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { sys_yes_no } = toRefs<any>(proxy?.useDict("sys_yes_no"));
@@ -138,12 +140,13 @@
const total = ref(0);
const dateRange = ref<[DateModelType, DateModelType]>(['', '']);
const detailFormRef = ref();
const queryFormRef = ref<ElFormInstance>();
const configFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
  visible: false,
  title: ''
});
// const configFormRef = ref<ElFormInstance>();
// const dialog = reactive<DialogOption>({
//   visible: false,
//   title: ''
// });
const initFormData: ConfigForm = {
  configId: undefined,
  configName: '',
@@ -178,15 +181,18 @@
  total.value = res.total;
  loading.value = false;
}
/** 取消按钮 */
const cancel = () => {
  reset();
  dialog.visible = false;
const openForm = (type: string, id?: number) => {
  detailFormRef.value.open(type, id)
}
/** 取消按钮 */
// const cancel = () => {
//   reset();
  // dialog.visible = false;
// }
/** 表单重置 */
const reset = () => {
  form.value = { ...initFormData };
  configFormRef.value?.resetFields();
  // configFormRef.value?.resetFields();
}
/** 搜索按钮操作 */
const handleQuery = () => {
@@ -206,31 +212,31 @@
  multiple.value = !selection.length;
}
/** 新增按钮操作 */
const handleAdd = () => {
  reset();
  dialog.visible = true;
  dialog.title = "添加参数";
}
// const handleAdd = () => {
//   reset();
  // dialog.visible = true;
  // dialog.title = "添加参数";
// }
/** 修改按钮操作 */
const handleUpdate = async (row?: ConfigVO) => {
  reset();
  const configId = row?.configId || ids.value[0];
  const res = await getConfig(configId);
  Object.assign(form.value, res.data);
  dialog.visible = true;
  dialog.title = "修改参数";
  // const configId = row?.configId || ids.value[0];
  // const res = await getConfig(configId);
  // Object.assign(form.value, res.data);
  // dialog.visible = true;
  // dialog.title = "修改参数";
}
/** 提交按钮 */
const submitForm = () => {
  configFormRef.value?.validate(async (valid: boolean) => {
    if (valid) {
      form.value.configId ? await updateConfig(form.value) : await addConfig(form.value);
      proxy?.$modal.msgSuccess("操作成功");
      dialog.visible = false;
      await getList();
    }
  });
}
// const submitForm = () => {
  // configFormRef.value?.validate(async (valid: boolean) => {
  //   if (valid) {
      // form.value.configId ? await updateConfig(form.value) : await addConfig(form.value);
      // proxy?.$modal.msgSuccess("操作成功");
      // dialog.visible = false;
      // await getList();
    // }
  // });
// }
/** 删除按钮操作 */
const handleDelete = async (row?: ConfigVO) => {
  const configIds = row?.configId || ids.value;