Ver código fonte

数据缓存

lilei 1 ano atrás
pai
commit
7b01af2612

+ 1 - 1
public/version.json

@@ -1,5 +1,5 @@
 {
   "message": "发现有新版本发布,确定更新系统?",
   "vendorJsVersion": "",
-  "version": 1709517308883
+  "version": 1709712839677
 }

+ 2 - 1
src/store/getters.js

@@ -29,7 +29,8 @@ const getters = {
   printUseing: state => state.app.printUseing,
   printSettingType: state => state.app.printSettingType,
   returnReason: state => state.app.returnReason,
-  cartCount: state => state.cart.cartCount
+  cartCount: state => state.cart.cartCount,
+  cacheData: state => state.app.cacheData
 }
 
 export default getters

+ 2 - 0
src/store/modules/app.js

@@ -50,6 +50,8 @@ const app = {
     printDefInk: undefined, // 默认喷墨打印机
     defectiveReturnReason: [], // 不良品申请退货列表
     goodReturnReason: [], // 良品申请退货列表
+    allArea: [], // 地区数据
+    custTypeAll: [], // 客户类型
   },
   mutations: {
     SET_SIDEBAR_TYPE: (state, type) => {

+ 11 - 5
src/views/common/areaList.js

@@ -73,11 +73,17 @@ const AreaList = {
     },
     //  省/市/区
     getArea () {
-      getAreaAll().then(res => {
-        if (res.status == 200) {
-          this.list = arrayToTree(res.data, 0)
-        }
-      })
+      const data = this.$store.state.app.allArea
+      if(data){
+        this.list = data
+      }else{
+        getAreaAll().then(res => {
+          if (res.status == 200) {
+            this.list = arrayToTree(res.data, 0)
+            this.$store.state.app.allArea = this.list
+          }
+        })
+      }
     },
     clearData () {
       this.handleChange([], null)

+ 13 - 7
src/views/common/custType.js

@@ -54,13 +54,19 @@ const custType = {
       this.$emit('input', value);
     },
     getList () {
-      custTypeFindAllList().then(res => {
-        if (res.status == 200) {
-          this.list = res.data
-        } else {
-          this.list = []
-        }
-      })
+      const data = this.$store.state.app.custTypeAll
+      if(data){
+        this.list = data
+      }else{
+        custTypeFindAllList().then(res => {
+          if (res.status == 200) {
+            this.list = res.data
+            this.$store.state.app.custTypeAll = res.data
+          } else {
+            this.list = []
+          }
+        })
+      }
     },
   },
 };

+ 12 - 94
src/views/customerManagement/customerInfo/edit.vue

@@ -46,31 +46,8 @@
           </a-row>
           <a-row :gutter="15">
             <a-col :span="24">
-              <a-form-model-item label="客户地址" required style="margin: 0;" :labelCol="{ span: 3}" :wrapperCol="{ span: 20 }">
-                <a-row :gutter="15">
-                  <!-- 客户地址 -->
-                  <a-col span="6">
-                    <a-form-model-item prop="provinceSn">
-                      <a-select id="customerManagementEdit-provinceSn" allowClear @change="getCityList" v-model="form.provinceSn" placeholder="请选择省">
-                        <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
-                      </a-select>
-                    </a-form-model-item>
-                  </a-col>
-                  <a-col span="6">
-                    <a-form-model-item prop="citySn">
-                      <a-select id="customerManagementEdit-citySn" allowClear @change="getAreaList" v-model="form.citySn" placeholder="请选择市">
-                        <a-select-option v-for="item in addrCityList" :value="item.areaSn" :key="item.areaSn + 'b'">{{ item.name }}</a-select-option>
-                      </a-select>
-                    </a-form-model-item>
-                  </a-col>
-                  <a-col span="6">
-                    <a-form-model-item prop="countySn">
-                      <a-select id="customerManagementEdit-countySn" allowClear @change="areaCharged" v-model="form.countySn" placeholder="请选择区/县">
-                        <a-select-option v-for="item in addrDistrictList" :value="item.areaSn" :key="item.areaSn + 'c'">{{ item.name }}</a-select-option>
-                      </a-select>
-                    </a-form-model-item>
-                  </a-col>
-                </a-row>
+              <a-form-model-item label="客户地址" prop="countySn" :labelCol="{ span: 3 }" :wrapperCol="{ span: 20 }">
+                <AreaList changeOnSelect ref="areaList" v-model="areaVal" @change="areaChange"></AreaList>
               </a-form-model-item>
             </a-col>
             <a-col :span="24">
@@ -139,12 +116,12 @@
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
-import { getArea } from '@/api/data'
 import custType from '@/views/common/custType.js'
+import AreaList from '@/views/common/areaList.js'
 import { custSave, custFindById, settleStyleFindAllList } from '@/api/customer'
 export default {
   name: 'CustomerManagementEdit',
-  components: { STable, VSelect, custType },
+  components: { STable, VSelect, custType, AreaList },
   mixins: [commonMixin],
   props: {
     model: {
@@ -177,16 +154,14 @@ export default {
         satelliteFlag: 0, //  是否卫星仓客户
         relationTypeDictValue: undefined, // 客户关系
         customerTypeSn: undefined, //  客户类型
-
         priceType: '', //  价格类型
         settleStyleSn: undefined //  收款方式
       },
+      areaVal:[],
       rules: {
         customerName: [{ required: true, message: '请输入客户名称', trigger: 'blur' }],
         contactMobile: [{ required: false, pattern: /^\d{11}$/, message: '请输入正确的手机号', trigger: 'blur' }],
-        provinceSn: [{ required: true, message: '请选择省', trigger: 'change' }],
-        citySn: [{ required: true, message: '请选择市', trigger: 'change' }],
-        countySn: [{ required: true, message: '请选择区/县', trigger: 'change' }],
+        countySn: [{ required: true, message: '请选择客户地址', trigger: 'change' }],
         priceType: [{ required: true, message: '请选择价格类型', trigger: 'change' }],
         settleStyleSn: [{ required: true, message: '请选择收款方式', trigger: 'change' }]
       },
@@ -204,14 +179,18 @@ export default {
       str = str.replace(/[\r\n]/g, '')
       this.form.customerName = str
     },
+    areaChange (val) {
+      this.form.provinceSn = val[0] ? val[0] : undefined
+      this.form.citySn = val[1] ? val[1] : undefined
+      this.form.countySn = val[2] ? val[2] : undefined
+    },
     //  获取客户信息
     getDetail () {
       custFindById({ id: this.$route.params.id }).then(res => {
         if (res.status == 200) {
-          if (res.data.provinceSn) { this.getArea('city', res.data.provinceSn) }
-          if (res.data.citySn) { this.getArea('district', res.data.citySn) }
           res.data.satelliteFlag = res.data.dealerFlag
           this.form = Object.assign(this.form, res.data)
+          this.areaVal = [res.data.provinceSn,res.data.citySn,res.data.countySn]
         } else {
           this.$refs.ruleForm.resetFields()
         }
@@ -263,69 +242,8 @@ export default {
     handleBack () {
       this.$router.push({ path: '/customerManagement/customerInfo/list' })
     },
-    // 获取城市列表
-    getCityList (val) {
-      this.addrCityList = []
-      this.addrDistrictList = []
-      this.form.citySn = undefined
-      this.form.countySn = undefined
-      if (val) {
-        this.getArea('city', val)
-        this.form.provinceName = this.addrProvinceList.find(item => item.areaSn == val).name
-      } else {
-        this.form.provinceName = ''
-      }
-    },
-    // 获取区县列表
-    getAreaList (val) {
-      this.addrDistrictList = []
-      this.form.countySn = undefined
-      if (val) {
-        this.getArea('district', val)
-        this.form.cityName = this.addrCityList.find(item => item.areaSn == val).name
-      } else {
-        this.form.cityName = ''
-      }
-    },
-    // 区县变更
-    areaCharged (val) {
-      if (val) {
-        this.form.countyName = this.addrDistrictList.find(item => item.areaSn == val).name
-      } else {
-        this.form.countyName = ''
-      }
-    },
-    //  省/市/区
-    getArea (leve, sn) {
-      let params
-      if (leve == 'province') {
-        params = { type: '2' }
-      } else {
-        params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
-      }
-      getArea(params).then(res => {
-        if (res.status == 200) {
-          if (leve == 'province') {
-            this.addrProvinceList = res.data || []
-          } else if (leve == 'city') {
-            this.addrCityList = res.data || []
-          } else if (leve == 'district') {
-            this.addrDistrictList = res.data || []
-          }
-        } else {
-          if (leve == 'province') {
-            this.addrProvinceList = []
-          } else if (leve == 'city') {
-            this.addrCityList = []
-          } else if (leve == 'district') {
-            this.addrDistrictList = []
-          }
-        }
-      })
-    },
     // 获取基础数据
     getBaseData () {
-      this.getArea('province') //  省市区
       this.getSettleStyleList() // 收款方式
       this.$refs.ruleForm.resetFields()
     },

+ 14 - 76
src/views/customerManagement/customerInfo/list.vue

@@ -37,33 +37,10 @@
                   <v-select code="FLAG" id="customerManagementList-dealerFlag" v-model="queryParam.dealerFlag" allowClear placeholder="请选择"></v-select>
                 </a-form-item>
               </a-col> -->
-              <a-col :md="10" :sm="24">
-                <a-row>
-                  <!-- 客户地址 -->
-                  <a-form-item label="客户地址">
-                    <a-col span="8">
-                      <a-form-item prop="provinceSn" style="margin: 0;">
-                        <a-select v-model="queryParam.provinceSn" allowClear @change="getCityList" placeholder="请选择省">
-                          <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
-                        </a-select>
-                      </a-form-item>
-                    </a-col>
-                    <a-col span="8">
-                      <a-form-item prop="citySn" style="margin: 0;">
-                        <a-select v-model="queryParam.citySn" allowClear @change="getAreaList" placeholder="请选择市">
-                          <a-select-option v-for="item in addrCityList" :value="item.areaSn" :key="item.areaSn + 'b'">{{ item.name }}</a-select-option>
-                        </a-select>
-                      </a-form-item>
-                    </a-col>
-                    <a-col span="8">
-                      <a-form-item prop="countySn" style="margin: 0;">
-                        <a-select v-model="queryParam.countySn" allowClear placeholder="请选择区/县">
-                          <a-select-option v-for="item in addrDistrictList" :value="item.areaSn" :key="item.areaSn + 'c'">{{ item.name }}</a-select-option>
-                        </a-select>
-                      </a-form-item>
-                    </a-col>
-                  </a-form-item>
-                </a-row>
+              <a-col :md="6" :sm="24">
+                <a-form-item label="客户地址">
+                  <AreaList changeOnSelect ref="areaList" @change="areaChange"></AreaList>
+                </a-form-item>
               </a-col>
               <a-col :md="4" :sm="24">
                 <a-form-item label="客户类型">
@@ -143,8 +120,8 @@
 
 <script>
 import { commonMixin } from '@/utils/mixin'
-import { getArea } from '@/api/data'
 import { custList, custDel, updateEnableStatus } from '@/api/customer'
+import AreaList from '@/views/common/areaList.js'
 import custType from '@/views/common/custType.js'
 import { STable, VSelect } from '@/components'
 import rangeDate from '@/views/common/rangeDate.vue'
@@ -152,7 +129,7 @@ import customerManagementDetailModal from './detailModal.vue'
 import mergeCustomerModal from './mergeCustomerModal.vue'
 export default {
   name: 'CustomerManagementList',
-  components: { STable, VSelect, customerManagementDetailModal, rangeDate, custType, mergeCustomerModal },
+  components: { STable, VSelect, customerManagementDetailModal, rangeDate, AreaList, custType, mergeCustomerModal },
   mixins: [commonMixin],
   data () {
     return {
@@ -221,6 +198,11 @@ export default {
       this.queryParam.saleBeginDate = date[0] ? date[0] : ''
       this.queryParam.saleEndDate = date[1] ? date[1] : ''
     },
+    areaChange (val) {
+      this.queryParam.provinceSn = val[0] ? val[0] : undefined
+      this.queryParam.citySn = val[1] ? val[1] : undefined
+      this.queryParam.countySn = val[2] ? val[2] : undefined
+    },
     //  重置
     resetSearchForm () {
       this.$refs.rangeSaleDate.resetDate()
@@ -237,6 +219,9 @@ export default {
       this.queryParam.enabledFlag = undefined
       this.addrCityList = []
       this.addrDistrictList = []
+      if(this.advanced){
+        this.$refs.areaList.clearData()
+      }
       this.$refs.table.refresh(true)
     },
     //  新增/编辑
@@ -313,58 +298,11 @@ export default {
         option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
       )
     },
-    // 获取城市列表
-    getCityList (val) {
-      this.addrCityList = []
-      this.addrDistrictList = []
-      this.queryParam.citySn = undefined
-      this.queryParam.countySn = undefined
-      if (val) {
-        this.getArea('city', val)
-      }
-    },
-    // 获取区县列表
-    getAreaList (val) {
-      this.addrDistrictList = []
-      this.queryParam.countySn = undefined
-      if (val) {
-        this.getArea('district', val)
-      }
-    },
-    //  省/市/区
-    getArea (leve, sn) {
-      let params
-      if (leve == 'province') {
-        params = { type: '2' }
-      } else {
-        params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
-      }
-      getArea(params).then(res => {
-        if (res.status == 200) {
-          if (leve == 'province') {
-            this.addrProvinceList = res.data || []
-          } else if (leve == 'city') {
-            this.addrCityList = res.data || []
-          } else if (leve == 'district') {
-            this.addrDistrictList = res.data || []
-          }
-        } else {
-          if (leve == 'province') {
-            this.addrProvinceList = []
-          } else if (leve == 'city') {
-            this.addrCityList = []
-          } else if (leve == 'district') {
-            this.addrDistrictList = []
-          }
-        }
-      })
-    },
     pageInit () {
       const _this = this
       this.$nextTick(() => { // 页面渲染完成后的回调
         _this.setTableH()
       })
-      this.getArea('province')
     },
     setTableH () {
       const tableSearchH = this.$refs.tableSearch.offsetHeight

+ 9 - 6
src/views/reportData/customerReport/list.vue

@@ -28,12 +28,12 @@
               <custType v-model="queryParam.customerTypeSn" allowClear placeholder="请选择客户类型"></custType>
             </a-form-item>
           </a-col>
-          <a-col :md="6" :sm="24">
-            <a-form-item label="客户所在区">
-              <AreaList id="chainSalesReportList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
-            </a-form-item>
-          </a-col>
           <template v-if="advanced">
+            <a-col :md="6" :sm="24">
+              <a-form-item label="客户所在区">
+                <AreaList id="chainSalesReportList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
+              </a-form-item>
+            </a-col>
             <a-col :md="6" :sm="24">
               <a-form-model-item label="产品分类">
                 <a-cascader
@@ -49,7 +49,7 @@
               </a-form-model-item>
             </a-col>
           </template>
-          <a-col :md="24" :sm="24" style="margin-bottom: 10px;text-align:center;">
+          <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
             <a-button type="primary" @click="handleSearch" :disabled="disabled" id="customerReportList-refresh">查询</a-button>
             <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="customerReportList-reset">重置</a-button>
             <a @click="advanced=!advanced" style="margin-left: 8px">
@@ -251,6 +251,9 @@ export default {
       this.productType = []
       this.$refs.ruleForm.resetFields()
       this.$refs.custSatelliteList.resetForm()
+      if(this.advanced){
+        this.$refs.areaList.clearData()
+      }
       this.totalData = null
       this.$refs.table.clearTable()
     },