zs 1 年之前
父節點
當前提交
ad4460a7e3
共有 1 個文件被更改,包括 8 次插入25 次删除
  1. 8 25
      src/views/system/buy/index.vue

+ 8 - 25
src/views/system/buy/index.vue

@@ -28,11 +28,8 @@
       <template v-slot:info>
         <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
           <cForm :span="24" :fields="formFields" :form="form" :rules="rules" @save="toSave">
-            <template #street>
-              <el-option @click="toChange(i)" v-for="i in streetList" :key="i._id" :label="i.name" :value="i._id"></el-option>
-            </template>
-            <template #community>
-              <el-option @click="toChange(i)" v-for="i in communityList" :key="i._id" :label="i.name" :value="i._id"></el-option>
+            <template #office>
+              <el-option @click="toChange(i)" v-for="i in officeList" :key="i._id" :label="i.name" :value="i._id"></el-option>
             </template>
             <template #is_use>
               <el-radio v-for="(i, index) in is_useList" :key="index" :label="i.value">{{ i.label }}</el-radio>
@@ -80,8 +77,7 @@ let total: Ref<number> = ref(0);
 let skip = 0;
 let limit: number = proxy.$limit;
 let fields: Ref<any[]> = ref([
-  { label: '所属街道', model: 'street', format: (i: any) => getDict(i, 'office') },
-  { label: '所属社区', model: 'community', format: (i: any) => getDict(i, 'office') },
+  { label: '街道/社区', model: 'office', format: (i: any) => getDict(i, 'office') },
   { label: '领导', model: 'leader', custom: true },
   { label: '会计', model: 'accounting', custom: true },
   { label: '是否使用', model: 'is_use', format: (i: any) => getDict(i, 'is_use') }
@@ -96,14 +92,13 @@ const dialog: Ref<{ type: string; show: boolean; title: string }> = ref({ type:
 let form: Ref<{ leader: Array<any>; accounting: Array<any> }> = ref({ leader: [], accounting: [] });
 // 表单
 let formFields: Ref<any[]> = ref([
-  { label: '所属街道', model: 'street', type: 'select' },
-  { label: '所属社区', model: 'community', type: 'select' },
+  { label: '街道/社区', model: 'office', type: 'select' },
   { label: '领导', model: 'leader', custom: true },
   { label: '会计', model: 'accounting', custom: true },
   { label: '是否使用', model: 'is_use', type: 'radio' }
 ]);
 const rules = reactive<FormRules>({
-  street: [{ required: true, message: '所属街道', trigger: 'blur' }],
+  office: [{ required: true, message: '街道/社区', trigger: 'blur' }],
   leader: [{ required: true, message: '领导', trigger: 'blur' }],
   accounting: [{ required: true, message: '会计', trigger: 'blur' }]
 });
@@ -112,8 +107,6 @@ let searchForm: Ref<any> = ref({});
 // 字典表
 let is_useList: Ref<any> = ref([]);
 let officeList: Ref<any> = ref([]);
-let streetList: Ref<any> = ref([]);
-let communityList: Ref<any> = ref([]);
 let ldList: Ref<any> = ref([]);
 let kjList: Ref<any> = ref([]);
 
@@ -149,9 +142,6 @@ const toChange = async (val: any) => {
   // 会计
   res = await userAxios.query({ role: 'kj', ...info });
   if (res.errcode == '0') kjList.value = res.data;
-  // 所属社区
-  res = await officeAxios.query({ belong: val._id, type: '1', is_use: '0' });
-  if (res.errcode == '0') communityList.value = res.data;
 };
 const getDict = (value: any, model: any) => {
   if (model == 'is_use') {
@@ -190,12 +180,8 @@ const toAdd = () => {
 };
 // 修改
 const toEdit = async (data: any) => {
-  let res;
   form.value = data;
-  // 所属社区
-  res = await officeAxios.query({ belong: data.street, type: '1', is_use: '0' });
-  if (res.errcode == '0') communityList.value = res.data;
-  toChange(data.street);
+  toChange(data.office);
   dialog.value = { title: '信息管理', show: true, type: '1' };
 };
 // 提交保存
@@ -206,7 +192,7 @@ const toSave = async (data: any) => {
   if (res.errcode == 0) {
     ElMessage({ type: `success`, message: `维护信息成功` });
     toClose();
-  }
+  } else ElMessage({ type: `warning`, message: `${res.errmsg}` });
 };
 // 删除
 const toDel = async (data: any) => {
@@ -228,12 +214,9 @@ const searchOther = async () => {
   // 是否使用
   res = await dictData.query({ type: 'is_use' });
   if (res.errcode == '0') is_useList.value = res.data;
-  // 街道
+  // 街道/社区
   res = await officeAxios.query({ is_use: '0' });
   if (res.errcode == '0') officeList.value = res.data;
-  // 所属街道
-  res = await officeAxios.query({ type: '0', is_use: '0' });
-  if (res.errcode == '0') streetList.value = res.data;
   // 领导
   res = await userAxios.query({ role: 'ld', status: '1' });
   if (res.errcode == '0') ldList.value = res.data;