Przeglądaj źródła

业务员管理

chenrui 3 lat temu
rodzic
commit
bad8afdf32

+ 25 - 0
src/config/router.config.js

@@ -319,6 +319,31 @@ export const asyncRouterMap = [
               }
               }
             ]
             ]
           }
           }
+          // {
+          //   path: '/salesManagement/salesman',
+          //   redirect: '/salesManagement/salesman/list',
+          //   name: 'salesman',
+          //   component: RouteView,
+          //   meta: {
+          //     title: '业务员管理',
+          //     icon: 'file-search'
+          //     // permission: 'M_giftRecordList'
+          //   },
+          //   hideChildrenInMenu: true,
+          //   children: [
+          //     {
+          //       path: 'list',
+          //       name: 'salesmanList',
+          //       component: () => import(/* webpackChunkName: "salesManagement" */ '@/views/salesManagement/salesman/list.vue'),
+          //       meta: {
+          //         title: '业务员列表',
+          //         icon: 'file-search',
+          //         hidden: true
+          //         // permission: 'M_giftRecordList'
+          //       }
+          //     }
+          //   ]
+          // }
         ]
         ]
       },
       },
       // 采购管理
       // 采购管理

+ 326 - 0
src/views/salesManagement/salesman/editModal.vue

@@ -0,0 +1,326 @@
+<template>
+  <a-modal
+    centered
+    class="supplierInfoEdit-modal"
+    :footer="null"
+    :maskClosable="false"
+    :title="modalTit"
+    v-model="isShow"
+    @cancle="isShow=false"
+    :width="800">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <!-- 表单 -->
+      <div>
+        <a-form-model
+          id="supplierInfoEdit-form"
+          ref="ruleForm"
+          :model="form"
+          :rules="rules"
+          :label-col="formItemLayout.labelCol"
+          :wrapper-col="formItemLayout.wrapperCol"
+        >
+          <a-form-model-item label="供应商名称" prop="supplierName">
+            <a-input
+              id="supplierInfoEdit-supplierName"
+              :maxLength="30"
+              v-model.trim="form.supplierName"
+              @change="filterEmpty"
+              placeholder="请输入供应商名称(最多30个字符)"
+              allowClear />
+          </a-form-model-item>
+          <a-form-model-item label="所在地区" required style="margin: 0;">
+            <a-row :gutter="20">
+              <!-- 所在地区 -->
+              <a-col span="8">
+                <a-form-model-item prop="provinceSn">
+                  <a-select id="supplierInfoEdit-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="8">
+                <a-form-model-item prop="citySn">
+                  <a-select id="supplierInfoEdit-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="8">
+                <a-form-model-item prop="countySn">
+                  <a-select id="supplierInfoEdit-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>
+          <a-form-model-item label="详细地址" prop="supplierAddress">
+            <a-input
+              id="supplierInfoEdit-supplierAddress"
+              :maxLength="60"
+              v-model="form.supplierAddress"
+              placeholder="请输入详细地址(最多60个字符)"
+              allowClear />
+          </a-form-model-item>
+          <a-form-model-item label="联系人" prop="contactPerson">
+            <a-input
+              id="supplierInfoEdit-contactPerson"
+              :maxLength="30"
+              v-model="form.contactPerson"
+              placeholder="请输入联系人(最多30个字符)"
+              allowClear />
+          </a-form-model-item>
+          <a-form-model-item label="联系电话" prop="contactTel">
+            <a-input
+              id="supplierInfoEdit-contactTel"
+              :maxLength="20"
+              v-model="form.contactTel"
+              placeholder="请输入联系电话(最多20个字符)"
+              allowClear />
+          </a-form-model-item>
+          <a-form-model-item label="主营内容" prop="businessScope">
+            <a-textarea
+              id="supplierInfoEdit-businessScope"
+              :maxLength="200"
+              v-model="form.businessScope"
+              placeholder="请输入主营内容(最多200个字符)"
+              allowClear />
+          </a-form-model-item>
+          <a-form-model-item label="状态" prop="enabledFlag" v-if="isState">
+            <a-radio-group
+              name="radioGroup"
+              v-model="form.enabledFlag"
+              id="supplierInfoEdit-enabledFlag" >
+              <a-radio :value="1">启用</a-radio>
+              <a-radio :value="0">禁用</a-radio>
+            </a-radio-group>
+          </a-form-model-item>
+        </a-form-model>
+        <div class="btn-cont">
+          <a-button type="primary" id="supplierInfoEdit-btn-submit" @click="handleSubmit">保存</a-button>
+          <a-button id="supplierInfoEdit-btn-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
+        </div>
+      </div>
+    </a-spin>
+  </a-modal>
+</template>
+
+<script>
+import { getArea } from '@/api/data'
+import { supplierDetail, supplierSave } from '@/api/supplier'
+export default {
+  name: 'SupplierInfoEditModal',
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    itemId: {
+      type: [Number, String],
+      default: ''
+    },
+    isState: { //  是否显示状态
+      type: Boolean,
+      default: true
+    }
+  },
+  computed: {
+    modalTit () {
+      return this.itemId ? '编辑' : '新增'
+    }
+  },
+  data () {
+    return {
+      spinning: false,
+      isShow: this.openModal, //  是否打开弹框
+      formItemLayout: {
+        labelCol: { span: 6 },
+        wrapperCol: { span: 16 }
+      },
+      form: {
+        supplierName: '', // 供应商名称
+        provinceSn: undefined, //  省
+        provinceName: '',
+        citySn: undefined, // 市
+        cityName: '',
+        countySn: undefined, // 区
+        countyName: '',
+        supplierAddress: '', //  详细地址
+        contactPerson: '', //  联系人
+        contactTel: '', //  联系电话
+        businessScope: '', //  主营内容
+        enabledFlag: 1 //  启禁用
+      },
+      rules: {
+        supplierName: [
+          { required: true, message: '请输入供应商名称', trigger: 'blur' }
+        ],
+        provinceSn: [
+          { required: true, message: '请选择省', trigger: 'change' }
+        ],
+        citySn: [
+          { required: true, message: '请选择市', trigger: 'change' }
+        ],
+        countySn: [
+          { required: true, message: '请选择区/县', trigger: 'change' }
+        ],
+        supplierAddress: [
+          { required: true, message: '请输入详细地址', trigger: 'blur' }
+        ],
+        contactPerson: [
+          { required: true, message: '请输入联系人', trigger: 'blur' }
+        ],
+        contactTel: [
+          { required: true, message: '请输入联系人电话', trigger: 'blur' }
+
+        ],
+        enabledFlag: [
+          { required: true, message: '请选择状态', trigger: 'change' }
+        ]
+      },
+      addrProvinceList: [], //  省下拉
+      addrCityList: [], //  市下拉
+      addrDistrictList: [] //  区下拉
+    }
+  },
+  methods: {
+    filterEmpty () {
+      let str = this.form.supplierName
+      str = str.replace(/\ +/g, '')
+      str = str.replace(/[ ]/g, '')
+      str = str.replace(/[\r\n]/g, '')
+      this.form.supplierName = str
+    },
+    //  获取供应商信息
+    getDetail () {
+      supplierDetail({ id: this.itemId }).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) }
+          this.form = Object.assign(this.form, res.data)
+          this.form.enabledFlag = Number(this.form.enabledFlag)
+        }
+      })
+    },
+    //  保存
+    handleSubmit (e) {
+      e.preventDefault()
+      const _this = this
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          const form = _this.form
+          form.id = this.itemId ? this.itemId : null
+          _this.spinning = true
+          supplierSave(form).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$emit('ok')
+              _this.isShow = false
+              _this.spinning = false
+            } else {
+              _this.spinning = false
+            }
+          })
+        } else {
+          console.log('error submit!!')
+          return false
+        }
+      })
+    },
+    // 获取城市列表
+    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 = []
+          }
+        }
+      })
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.$refs.ruleForm.resetFields()
+        this.addrCityList = []
+        this.addrDistrictList = []
+      } else {
+        this.getArea('province')
+      }
+    },
+    itemId (newValue, oldValue) {
+      if (this.isShow && newValue) { //  编辑
+        this.getDetail()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less">
+  .supplierInfoEdit-modal{
+    .ant-modal-body {
+      padding: 40px 40px 24px;
+    }
+    .btn-cont {
+      text-align: center;
+      margin: 35px 0 10px;
+    }
+  }
+</style>

+ 138 - 0
src/views/salesManagement/salesman/list.vue

@@ -0,0 +1,138 @@
+<template>
+  <a-card size="small" :bordered="false" class="salesmanList-wrap">
+    <!-- 搜索条件 -->
+    <div ref="tableSearch" class="table-page-search-wrapper">
+      <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
+        <a-row :gutter="15">
+          <a-col :md="6" :sm="24">
+            <a-form-item label="供应商名称">
+              <a-input id="salesmanList-supplierName" v-model.trim="queryParam.supplierName" allowClear placeholder="请输入供应商名称"/>
+            </a-form-item>
+          </a-col>
+          <a-col :md="6" :sm="24">
+            <a-form-item label="状态">
+              <v-select code="ENABLE_FLAG" id="salesmanList-enabledFlag" v-model="queryParam.enabledFlag" allowClear placeholder="请选择状态"></v-select>
+            </a-form-item>
+          </a-col>
+          <a-col :md="6" :sm="24">
+            <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="salesmanList-refresh">查询</a-button>
+            <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="salesmanList-reset">重置</a-button>
+          </a-col>
+        </a-row>
+      </a-form>
+    </div>
+    <!-- 操作按钮 -->
+    <div class="table-operator">
+      <a-button
+        id="salesmanList-add"
+        type="primary"
+        class="button-error"
+        @click="handleEdit()">新增</a-button>
+    </div>
+    <!-- 列表 -->
+    <s-table
+      class="sTable fixPagination"
+      ref="table"
+      :style="{ height: tableHeight+84.5+'px' }"
+      size="small"
+      :rowKey="(record) => record.id"
+      :columns="columns"
+      :data="loadData"
+      :scroll="{ x: 1310, y: tableHeight }"
+      bordered>
+      <!-- 操作 -->
+      <template slot="action" slot-scope="text, record">
+        <a-button
+          size="small"
+          type="link"
+          class="button-info"
+          @click="handleEdit(record)"
+          id="salesmanList-edit-btn">编辑</a-button>
+        <!-- <span v-else>--</span> -->
+      </template>
+    </s-table>
+    <!-- 供应商 -->
+    <salesman-edit-modal :itemId="itemId" :openModal="openModal" @close="closeModal" />
+  </a-card>
+</template>
+
+<script>
+import { STable, VSelect } from '@/components'
+import { supplierList } from '@/api/supplier'
+import salesmanEditModal from './editModal.vue'
+export default {
+  components: { STable, VSelect, salesmanEditModal },
+  data () {
+    return {
+      queryParam: { //  查询条件
+        supplierName: '', //  供应商名称
+        enabledFlag: undefined //  状态
+      },
+      tableHeight: 0,
+      disabled: false, //  查询、重置按钮是否可操作
+      columns: [
+        { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
+        { title: '供应商名称', dataIndex: 'supplierName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '地址', dataIndex: 'address', width: 200, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
+        { title: '联系人', dataIndex: 'contactPerson', width: 150, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
+        { title: '联系电话', dataIndex: 'contactTel', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '主营内容', dataIndex: 'businessScope', width: 200, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
+        { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '状态', dataIndex: 'enabledFlagDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.disabled = true
+        this.spinning = true
+        return supplierList(Object.assign(parameter, this.queryParam)).then(res => {
+          const data = res.data
+          const no = (data.pageNo - 1) * data.pageSize
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = no + i + 1
+            const provinceName = data.list[i].provinceName ? data.list[i].provinceName : ''
+            const cityName = data.list[i].cityName ? data.list[i].cityName : ''
+            const countyName = data.list[i].countyName ? data.list[i].countyName : ''
+            const supplierAddress = data.list[i].supplierAddress ? data.list[i].supplierAddress : ''
+            data.list[i].address = provinceName + cityName + countyName + supplierAddress
+          }
+          this.disabled = false
+          this.spinning = false
+          return data
+        })
+      },
+      itemId: '', //  当前id
+      openModal: false // 弹框
+    }
+  },
+  methods: {
+    //  重置
+    resetSearchForm () {
+      this.queryParam.supplierName = ''
+      this.queryParam.enabledFlag = undefined
+      this.$refs.table.refresh(true)
+    },
+    //  新增/编辑
+    handleEdit (row) {
+      this.itemId = row && row.id ? row.id : null
+      this.openModal = true
+    },
+    // 关闭弹框
+    closeModal () {
+      this.itemId = ''
+      this.openModal = false
+      this.$refs.table.refresh(true)
+    },
+    setTableH () {
+      const tableSearchH = this.$refs.tableSearch.offsetHeight
+      this.tableHeight = window.innerHeight - tableSearchH - 235
+    }
+  },
+  mounted () {
+    const _this = this
+    this.$nextTick(() => { // 页面渲染完成后的回调
+      _this.setTableH()
+    })
+  }
+}
+</script>