Browse Source

2024-12-25

cmy 10 months ago
parent
commit
85d2250163
3 changed files with 126 additions and 124 deletions
  1. 2 4
      src/views/Goods/list/index.vue
  2. 123 119
      src/views/Store/list/components/Write.vue
  3. 1 1
      src/views/Store/list/index.vue

+ 2 - 4
src/views/Goods/list/index.vue

@@ -69,7 +69,6 @@ const tabsConfig = reactive({
 })
 const currentPage = ref(1)
 const pageSize = ref(10)
-const total = ref(0)
 const dataList = ref<any[]>([])
 const loading = ref(false)
 
@@ -103,12 +102,11 @@ const getList = async () => {
         item.is_show_bol = Boolean(item.is_show)
         return item
       })
-      total.value = data.count
       tabsConfig[activeName.value].total = data.count
     } else {
       // 处理数据为空的情况
       dataList.value = []
-      total.value = 0
+      tabsConfig[activeName.value].total = 0
     }
   } catch (error) {
     // 异常处理
@@ -532,7 +530,7 @@ const audit = async (id, is_verify, refusal) => {
       layout="sizes, prev, pager, next, jumper, ->, total"
       :page-sizes="[10, 20, 30, 40, 50, 100]"
       class="mt-10px"
-      :total="total"
+      :total="tabsConfig[activeName].total"
     />
   </ContentWrap>
 

+ 123 - 119
src/views/Store/list/components/Write.vue

@@ -2,10 +2,10 @@
 import { Form, FormSchema } from '@/components/Form'
 import { UpImgButtom } from '@/components/UpFile'
 import { useForm } from '@/hooks/web/useForm'
-import { PropType, watch, ref, onMounted, unref } from 'vue'
+import { PropType, watch, ref, onMounted, unref, reactive, nextTick } from 'vue'
 import { useValidator } from '@/hooks/web/useValidator'
 import { cloneDeep } from 'lodash-es'
-import { ElAutocomplete } from 'element-plus'
+import { ElAutocomplete, FormRules } from 'element-plus'
 import { getConfigKey, getMapSearch } from '@/api/system/admin'
 import { mapAddressData } from '@/api/system/admin/types'
 // import { UserList } from '@/components/UserList'
@@ -29,24 +29,75 @@ const checkedUser = async (res: any) => {
     // gender: res.sex || 0
   })
 }
-
+const rules = reactive<FormRules>({
+  name: [required('请填写门店名称')],
+  uid: [required('请选择绑定用户')],
+  introduction: [required('请填写门店简介')],
+  phone: [required('请填写联系号码')],
+  logo: [required('请选择logo')],
+  slide_images: [required('请选择推荐图')],
+  manager_name: [required('请填写店长名称')],
+  valid_range: [required('请填写有效距离')],
+  store_account: [
+    {
+      required: true,
+      message: '请填写登录账号'
+    }
+  ],
+  store_password: [
+    {
+      required: true,
+      message: '请输入登录密码'
+    }
+  ],
+  true_password: [
+    {
+      required: true,
+      validator: (_, val, callback) => {
+        // console.log(item)
+        getFormData().then((formData) => {
+          if (!val) return callback()
+          if (formData.store_password !== val) {
+            callback(new Error('两次密码不一致'))
+          } else {
+            callback()
+          }
+        })
+      }
+    }
+  ],
+  detailed_address: [
+    {
+      required: true,
+      validator: (_, val, callback) => {
+        // console.log(actionAddress.value, val, 'actionAddress.value')
+        if (!actionAddress.value || !val) {
+          callback(new Error('请选择地址'))
+        } else {
+          callback()
+        }
+      }
+    }
+  ]
+})
 onMounted(async () => {
   const res = await getConfigKey('tengxun_map_key')
   if (res) {
     mapKey.value = res.data.tengxun_map_key
   }
+  let required = true
   if (props.currentRow) {
-    console.log(props.currentRow, 'props.currentRow')
-    rules.value.store_account = [
-      {
-        required: false
-      }
-    ]
-    rules.value.store_password = [
-      {
-        required: false
-      }
-    ]
+    required = false
+  }
+  await nextTick()
+  if (rules && rules.store_account) {
+    rules.store_account[0].required = required
+  }
+  if (rules && rules.store_password) {
+    rules.store_password[0].required = required
+  }
+  if (rules && rules.true_password) {
+    rules.true_password[0].required = required
   }
 })
 
@@ -133,9 +184,6 @@ const formSchema = ref<FormSchema[]>([
     field: 'type',
     label: '类型',
     component: 'Select',
-    colProps: {
-      span: 24
-    },
     value: 1,
     componentProps: {
       options: [
@@ -154,69 +202,15 @@ const formSchema = ref<FormSchema[]>([
     field: 'name',
     label: '门店名称',
     component: 'Input',
-    colProps: {
-      span: 24
-    },
     componentProps: {
       placeholder: '请输入门店名称'
     }
   },
-  {
-    field: 'logo',
-    label: '门店LOGO',
-    component: 'CheckboxGroup',
-    componentProps: {
-      placeholder: '选择LOGO'
-    },
-    formItemProps: {
-      slots: {
-        default: (data) => {
-          return (
-            <>
-              <UpImgButtom v-model={data.logo}></UpImgButtom>
-            </>
-          )
-        }
-      }
-    }
-  },
-  {
-    field: 'introduction',
-    label: '简介',
-    component: 'Input',
-    colProps: {
-      span: 24
-    },
-    componentProps: {
-      placeholder: '请输入门店简介'
-    }
-  },
-  {
-    field: 'slide_images',
-    label: '推荐图',
-    component: 'CheckboxGroup',
-    componentProps: {
-      placeholder: '选择推荐图'
-    },
-    formItemProps: {
-      slots: {
-        default: (data) => {
-          return (
-            <>
-              <UpImgButtom num={3} v-model={data.slide_images}></UpImgButtom>
-            </>
-          )
-        }
-      }
-    }
-  },
+
   {
     field: 'manager_name',
     label: '店长',
     component: 'Input',
-    colProps: {
-      span: 24
-    },
     componentProps: {
       placeholder: '请输入店长名称'
     }
@@ -225,9 +219,6 @@ const formSchema = ref<FormSchema[]>([
     field: 'phone',
     label: '联系电话',
     component: 'Input',
-    colProps: {
-      span: 24
-    },
     componentProps: {
       placeholder: '请输入联系电话'
     }
@@ -236,9 +227,6 @@ const formSchema = ref<FormSchema[]>([
     field: 'store_account',
     label: '登录账号',
     component: 'Input',
-    colProps: {
-      span: 24
-    },
     componentProps: {
       strength: true,
       placeholder: '请输入登录账号'
@@ -247,9 +235,15 @@ const formSchema = ref<FormSchema[]>([
   {
     field: 'store_password',
     label: '登录密码',
-    colProps: {
-      span: 24
-    },
+    component: 'InputPassword',
+    componentProps: {
+      strength: true,
+      placeholder: '请输入登录密码'
+    }
+  },
+  {
+    field: 'true_password',
+    label: '重复登录密码',
     component: 'InputPassword',
     componentProps: {
       strength: true,
@@ -265,41 +259,76 @@ const formSchema = ref<FormSchema[]>([
   //     placeholder: '请输入重复输入登录密码'
   //   }
   // },
+
   {
-    field: 'valid_range',
-    label: '有效距离(km)',
+    field: 'logo',
+    label: '门店LOGO',
+    component: 'CheckboxGroup',
+    formItemProps: {
+      slots: {
+        default: (data) => {
+          return (
+            <>
+              <UpImgButtom v-model={data.logo}></UpImgButtom>
+            </>
+          )
+        }
+      }
+    }
+  },
+  {
+    field: 'slide_images',
+    label: '推荐图',
+    component: 'CheckboxGroup',
+    formItemProps: {
+      slots: {
+        default: (data) => {
+          return (
+            <>
+              <UpImgButtom num={3} v-model={data.slide_images}></UpImgButtom>
+            </>
+          )
+        }
+      }
+    }
+  },
+  {
+    field: 'introduction',
+    label: '简介',
     component: 'Input',
     colProps: {
       span: 24
     },
     componentProps: {
-      placeholder: '请输入有效距离'
+      type: 'textarea',
+      rows: 2,
+      placeholder: '请输入门店简介'
     }
   },
+
   {
     field: 'product_status',
-    colProps: {
-      span: 24
-    },
     label: '自主添加商品',
     component: 'Switch'
   },
   {
     field: 'product_verify_status',
-    colProps: {
-      span: 24
-    },
     label: '商品免审核',
     component: 'Switch'
   },
   {
     field: 'is_show',
-    colProps: {
-      span: 24
-    },
     label: '是否显示',
     component: 'Switch'
   },
+  {
+    field: 'valid_range',
+    label: '有效距离(km)',
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入有效距离'
+    }
+  },
   {
     field: 'detailed_address',
     label: '省市区地址',
@@ -379,36 +408,11 @@ const formSchema = ref<FormSchema[]>([
   }
 ])
 
-const rules = ref({
-  name: [required('请填写门店名称')],
-  uid: [required('请选择绑定用户')],
-  introduction: [required('请填写门店简介')],
-  phone: [required('请填写联系号码')],
-  logo: [required('请选择logo')],
-  slide_images: [required('请选择推荐图')],
-  manager_name: [required('请填写店长名称')],
-  valid_range: [required('请填写有效距离')],
-  store_account: [required('请填写登录账号')],
-  store_password: [required('请填写登录密码')],
-  detailed_address: [
-    {
-      required: true,
-      validator: (_, val, callback) => {
-        console.log(actionAddress.value, val, 'actionAddress.value')
-        if (!actionAddress.value || !val) {
-          callback(new Error('请选择地址'))
-        } else {
-          callback()
-        }
-      }
-    }
-  ]
-})
-
 const { formRegister, formMethods } = useForm()
 const { setValues, getFormData, getElFormExpose } = formMethods
 
 const submit = async () => {
+  console.log('触发')
   const elForm = await getElFormExpose()
   const valid = await elForm?.validate().catch((err) => {
     console.log(err)

+ 1 - 1
src/views/Store/list/index.vue

@@ -351,7 +351,7 @@ const save = async () => {
     />
   </ContentWrap>
 
-  <Dialog v-model="dialogVisible" :title="dialogTitle" width="500px" maxHeight="700px">
+  <Dialog v-model="dialogVisible" :title="dialogTitle" width="800px" maxHeight="700px">
     <Write ref="writeRef" :current-row="currentRow" />
     <template #footer>
       <BaseButton type="primary" :loading="saveLoading" @click="save">