asd26269546 1 سال پیش
والد
کامیت
84b4fbb1c7
1فایلهای تغییر یافته به همراه111 افزوده شده و 47 حذف شده
  1. 111 47
      src/views/system/addressConfig/index.vue

+ 111 - 47
src/views/system/addressConfig/index.vue

@@ -12,10 +12,10 @@
       <el-table-column prop="name" label="名称" />
       <el-table-column prop="address" label="操作">
         <template #default="scope">
-            <el-button size="small" @click="addAddress(scope.row)">
+            <el-button size="small" @click="addAddress(scope.row,'add')">
               新增
             </el-button>
-            <el-button size="small" @click="handleEdit(scope.$index, scope.row)"
+            <el-button size="small" @click="addAddress(scope.row,'edit')"
             >修改</el-button>
             <el-button
             size="small"
@@ -48,11 +48,14 @@
         ref="submit"
         v-loading="loadingDialog"
       >
-        <template #footer>
-          <el-button @click="dialogVisible = false">取 消</el-button>
-          <el-button type="primary" @click="submit">确 定</el-button>
-        </template>
+        
       </byForm>
+      <template #footer>
+        <el-button @click="dialogVisible = false" size="large">取 消</el-button>
+        <el-button type="primary" @click="submitForm()" size="large"
+          >确 定</el-button
+        >
+      </template>
     </el-dialog>
   </div>
 </template>
@@ -60,6 +63,7 @@
 <script setup name="Config">
 import { listConfig, getConfig, delConfig, addConfig, updateConfig, refreshCache } from "@/api/system/config";
 import byForm from "@/components/byForm";
+import { ElMessage, ElMessageBox } from "element-plus"; 
 const { proxy } = getCurrentInstance();
 const { sys_yes_no } = proxy.useDict("sys_yes_no");
 
@@ -104,15 +108,47 @@ const formData = reactive({
 const formConfig = computed(() => {
   return [
     {
-      type: "title",
-      title: "账户信息",
+      type: "input",
+      prop: "parentName",
+      label: "父级名称",
+      disabled: true,
+      isShow:modalType.value == 'add'
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "名称",
+    },
+    {
+      type: "input",
+      prop: "chineseName",
+      label: "中文名",
+    },
+    {
+      type: "select",
+      prop: "levelCode",
+      label: "层级",
+      data:[
+        {
+          label:'国家',
+          value:1
+        },
+        {
+          label:'省份/洲',
+          value:2
+        },
+        {
+          label:'市区',
+          value:3
+        }
+      ]
     },
     {
-      type: "slot",
-      prop: "transactionTime",
-      slotName: "transactionTime",
-      label: "交易时间",
+      type: "input",
+      prop: "code",
+      label: "地区代码",
     },
+    
   ];
 });
 
@@ -162,17 +198,28 @@ const dialogVisible = ref(false);
 const modalType = ref('add');
 const loadingDialog = ref(false);
 
-const addAddress = (row) => {
+const addAddress = (row,type) => {
   console.log(row)
-  dialogVisible.value = true;
-  modalType.value = 'add';
-  formData.data = {
-    parentName:row.name,
-    parentId:row.id,
-    name:undefined,
-    chineseName:undefined,
-    address:undefined,
+  
+  modalType.value = type;
+  if(type == 'edit') {
+    formData.data = {
+      ...row,
+      chinese_name:row.chineseName || row.chinese_name,
+      level_code:row.levelCode || row.level_code,
+    }
+    console.log(formData.data)
+  }else{
+    formData.data = {
+      parentName:row.name,
+      parentId:row.id,
+      name:undefined,
+      chineseName:undefined,
+      address:undefined,
+    }
   }
+  dialogVisible.value = true;
+  
 }
 
 /** 表单重置 */
@@ -220,35 +267,52 @@ function handleUpdate(row) {
    title.value = "修改参数";
  });
 }
+const submit = ref(null);
 /** 提交按钮 */
-function submitForm() {
- proxy.$refs["configRef"].validate(valid => {
-   if (valid) {
-     if (form.value.configId != undefined) {
-       updateConfig(form.value).then(response => {
-         proxy.$modal.msgSuccess("修改成功");
-         open.value = false;
-         getList();
-       });
-     } else {
-       addConfig(form.value).then(response => {
-         proxy.$modal.msgSuccess("新增成功");
-         open.value = false;
-         getList();
-       });
-     }
-   }
- });
-}
+const submitForm = () => {
+  submit.value.handleSubmit(() => {
+    loadingDialog.value = true;
+    proxy.post("/customizeArea/" + modalType.value, formData.data).then(
+      () => {
+        ElMessage({
+          message: modalType.value == "add" ? "添加成功" : "编辑成功",
+          type: "success",
+        });
+        dialogVisible.value = false;
+        tableData.value = []
+        getList();
+      },
+      (err) => {
+        console.log(err);
+        loadingDialog.value = false;
+      }
+    );
+  });
+};
 /** 删除按钮操作 */
 function handleDelete(row) {
- const configIds = row.configId || ids.value;
- proxy.$modal.confirm('是否确认删除参数编号为"' + configIds + '"的数据项?').then(function () {
-   return delConfig(configIds);
- }).then(() => {
-   getList();
-   proxy.$modal.msgSuccess("删除成功");
- }).catch(() => {});
+  ElMessageBox.confirm(
+    "此操作将永久删除该数据, 是否继续?",
+    "提示",
+    {
+      confirmButtonText: "确定",
+      cancelButtonText: "取消",
+      type: "warning",
+    }
+  ).then(() => {
+    proxy
+      .post("/customizeArea/delete", {
+        id: row.id,
+      })
+      .then(() => {
+        ElMessage({
+          message: "删除成功",
+          type: "success",
+        });
+        tableData.value = []
+        getList();
+      });
+  });
 }
 /** 导出按钮操作 */
 function handleExport() {