瀏覽代碼

对接经销商账号管理

chenrui 4 年之前
父節點
當前提交
485631a936

+ 18 - 15
src/views/dealerManagement/dealerAccountManagement/detailModal.vue

@@ -4,17 +4,17 @@
     class="dealerAccountDetail-modal"
     :footer="null"
     :maskClosable="false"
-    title="账号信息"
+    title="详情"
     v-model="isShow"
     @cancle="isShow=false"
     :width="800">
     <div v-if="detailData">
-      <a-descriptions bordered size="default">
-        <a-descriptions-item label="经销商名称:">{{ detailData.productName || '--' }}</a-descriptions-item>
-        <a-descriptions-item label="管理员姓名:">{{ detailData.productCode || '--' }}</a-descriptions-item>
-        <a-descriptions-item label="管理员手机:">{{ detailData.origCode || '--' }}</a-descriptions-item>
-        <a-descriptions-item label="管理员账号:">{{ detailData.origCode || '--' }}</a-descriptions-item>
-        <a-descriptions-item label="最大可开通用户数(不含管理员账号):">{{ detailData.origCode || '--' }}</a-descriptions-item>
+      <a-descriptions bordered size="small" :column="2">
+        <a-descriptions-item label="经销商名称:">{{ detailData.org.name || '--' }}</a-descriptions-item>
+        <a-descriptions-item label="管理员姓名:">{{ detailData.name || '--' }}</a-descriptions-item>
+        <a-descriptions-item label="管理员手机:">{{ detailData.phone || '--' }}</a-descriptions-item>
+        <a-descriptions-item label="管理员账号:">{{ detailData.loginName || '--' }}</a-descriptions-item>
+        <a-descriptions-item label="最大可开通用户数(含管理员账号):">{{ detailData.org.childUserMaxNum || '--' }}</a-descriptions-item>
       </a-descriptions>
       <div class="btn-cont"><a-button id="dealerAccountDetail-modal-back" @click="isShow = false">关闭</a-button></div>
     </div>
@@ -22,7 +22,7 @@
 </template>
 
 <script>
-// import { dealerProductDetail } from '@/api/dealerProduct'
+import { dealerUserDetail } from '@/api/dealer'
 export default {
   name: 'DealerAccountDetailModal',
   props: {
@@ -44,13 +44,13 @@ export default {
   methods: {
     //  获取详情
     getDetail () {
-      // dealerProductDetail({ id: this.itemId }).then(res => {
-      //   if (res.status == 200) {
-      //     this.detailsData = res.data
-      //   } else {
-      //     this.detailsData = null
-      //   }
-      // })
+      dealerUserDetail({ id: this.itemId }).then(res => {
+        if (res.status == 200) {
+          this.detailData = res.data
+        } else {
+          this.detailData = null
+        }
+      })
     }
   },
   watch: {
@@ -78,6 +78,9 @@ export default {
     .ant-modal-body {
       padding: 40px 40px 24px;
     }
+    .ant-descriptions-item-label.ant-descriptions-item-colon{
+      width: 133px;
+    }
     .btn-cont {
       text-align: center;
       margin: 35px 0 10px;

+ 31 - 11
src/views/dealerManagement/dealerAccountManagement/editModal.vue

@@ -19,7 +19,8 @@
         :wrapper-col="formItemLayout.wrapperCol"
       >
         <a-form-model-item label="经销商名称" prop="tenantSn">
-          <custList ref="custList" id="dealerAccountEdit-tenantSn" @change="custChange"></custList>
+          <custList ref="custList" v-if="!itemId" id="dealerAccountEdit-tenantSn" @change="custChange"></custList>
+          <span v-else>{{ detailData.org.name }}</span>
         </a-form-model-item>
         <a-form-model-item label="管理员姓名" prop="name">
           <a-input
@@ -42,10 +43,11 @@
             id="dealerAccountEdit-loginName"
             :maxLength="50"
             v-model.trim="form.loginName"
+            :disabled="itemId"
             placeholder="请输入管理员账号,字母/数字(最多50个字符)"
             allowClear />
         </a-form-model-item>
-        <a-form-model-item label="管理员密码" prop="password">
+        <a-form-model-item label="管理员密码" prop="password" v-if="!itemId">
           <a-input
             id="dealerAccountEdit-password"
             :maxLength="50"
@@ -54,7 +56,7 @@
             placeholder="请输入管理员密码,字母/数字(最多50个字符)"
             allowClear />
         </a-form-model-item>
-        <a-form-model-item label="最大可开通用户数" prop="org.childUserMaxNum" extra="(含管理员账号)">
+        <a-form-model-item label="最大可开通用户数" prop="org.childUserMaxNum" extra="(含管理员账号)">
           <a-input-number
             id="dealerAccountEdit-childUserMaxNum"
             v-model="form.org.childUserMaxNum"
@@ -75,7 +77,7 @@
 
 <script>
 import custList from '@/views/common/custList.vue'
-import { dealerUserSave } from '@/api/dealer'
+import { dealerUserSave, dealerUserDetail } from '@/api/dealer'
 export default {
   name: 'DealerAccountEditModal',
   components: { custList },
@@ -87,10 +89,6 @@ export default {
     itemId: {
       type: [Number, String],
       default: ''
-    },
-    nowData: {
-      type: Object,
-      default: null
     }
   },
   data () {
@@ -118,7 +116,7 @@ export default {
         password: [{ required: true, message: '请输入管理员密码', trigger: 'blur' }, { pattern: /^[0-9a-zA-Z]+$/, message: '管理员密码由字母和数字组成' }],
         'org.childUserMaxNum': [{ required: true, message: '请输入最大可开通用户数', trigger: 'blur' }]
       },
-      productBrandList: []
+      detailData: null //  详情数据
     }
   },
   methods: {
@@ -132,8 +130,8 @@ export default {
         if (valid) {
           const formData = JSON.parse(JSON.stringify(_this.form))
           formData.id = _this.itemId ? _this.itemId : undefined
-          if (!_this.itemId) {
-            formData.loginFlag = 1
+          if (_this.itemId) {
+            delete formData.password
           }
           dealerUserSave(formData).then(res => {
             if (res.status == 200) {
@@ -146,6 +144,23 @@ export default {
           return false
         }
       })
+    },
+    //  获取详情
+    getDetail () {
+      dealerUserDetail({ id: this.itemId }).then(res => {
+        if (res.status == 200) {
+          this.detailData = res.data
+          this.form.tenantSn = this.detailData.tenantSn || ''
+          this.form.name = this.detailData.name || ''
+          this.form.phone = this.detailData.phone || ''
+          this.form.loginName = this.detailData.loginName || ''
+          this.form.password = this.detailData.password || ''
+          this.form.org.childUserMaxNum = this.detailData.org.childUserMaxNum || ''
+        } else {
+          this.detailData = null
+          this.$refs.ruleForm.resetFields()
+        }
+      })
     }
   },
   watch: {
@@ -158,6 +173,11 @@ export default {
       if (!newValue) {
         this.$emit('close')
       }
+    },
+    itemId (newValue, oldValue) {
+      if (this.isShow && newValue) {
+        this.getDetail()
+      }
     }
   }
 }

+ 38 - 27
src/views/dealerManagement/dealerAccountManagement/list.vue

@@ -6,17 +6,17 @@
         <a-row :gutter="15">
           <a-col :md="6" :sm="24">
             <a-form-item label="经销商名称">
-              <a-input id="dealerAccountList-productBrandName" v-model.trim="queryParam.productBrandName" allowClear placeholder="请输入经销商名称"/>
+              <a-input id="dealerAccountList-name" v-model.trim="queryParam.org.name" allowClear placeholder="请输入经销商名称"/>
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="24">
             <a-form-item label="管理员账号">
-              <a-input id="dealerAccountList-productBrandName" v-model.trim="queryParam.productBrandName" allowClear placeholder="请输入管理员账号"/>
+              <a-input id="dealerAccountList-loginName" v-model.trim="queryParam.loginName" allowClear placeholder="请输入管理员账号"/>
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="24">
             <a-form-item label="账号状态">
-              <v-select code="ENABLE_FLAG" id="dealerAccountList-state" v-model="queryParam.state" allowClear placeholder="请选择账号状态"></v-select>
+              <v-select code="ENABLE_FLAG" id="dealerAccountList-loginFlag" v-model="queryParam.loginFlag" allowClear placeholder="请选择账号状态"></v-select>
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="24">
@@ -41,8 +41,13 @@
       :scroll="{ x: 1310, y: tableHeight }"
       bordered>
       <!-- 账号状态 -->
-      <template slot="enableAction" slot-scope="text, record">
-        <a-switch checkedChildren="启用" unCheckedChildren="禁用" v-model="record.enabledFlag" @change="changeFlagHandle(text, record)"/>
+      <template slot="loginFlag" slot-scope="text, record">
+        <a-switch
+          id="dealerAccountList-enable"
+          checkedChildren="启用"
+          unCheckedChildren="禁用"
+          @change="changeStatus(record)"
+          :checked="record.loginFlag == 1 ? true : false" />
         <!-- <span v-else>{{ record.loginFlag==1?'已启用':'已禁用' }}</span> -->
       </template>
       <!-- 操作 -->
@@ -68,25 +73,28 @@
 import { STable, VSelect } from '@/components'
 import dealerAccountEditModal from './editModal.vue'
 import dealerAccountDetailModal from './detailModal.vue'
-import { dealerUserList } from '@/api/dealer'
+import { dealerUserList, dealerUserEnable, dealerUserResetP } from '@/api/dealer'
 export default {
   components: { STable, VSelect, dealerAccountEditModal, dealerAccountDetailModal },
   data () {
     return {
       tableHeight: 0,
       queryParam: { //  查询条件
-        // productBrandName: '', //  品牌名称
-        // enabledFlag: undefined //  状态
+        org: {
+          name: ''
+        },
+        loginName: '',
+        loginFlag: undefined
       },
       disabled: false, //  查询、重置按钮是否可操作
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
         { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
-        { title: '经销商名称', dataIndex: 'productBrandName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '管理员姓名', dataIndex: 'creatseDate', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '管理员账号', dataIndex: 'producstBrandName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '授权用户数', dataIndex: 'productssBrandName', width: 140, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '状态', scopedSlots: { customRender: 'enableAction' }, width: 150, align: 'center' },
+        { title: '经销商名称', dataIndex: 'org.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '管理员姓名', dataIndex: 'name', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '管理员账号', dataIndex: 'loginName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '授权用户数', dataIndex: 'org.childUserMaxNum', width: 140, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '状态', scopedSlots: { customRender: 'loginFlag' }, width: 150, align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
       ],
       // 加载数据方法 必须为 Promise 对象
@@ -100,6 +108,7 @@ export default {
           const no = (data.pageNo - 1) * data.pageSize
           for (var i = 0; i < data.list.length; i++) {
             data.list[i].no = no + i + 1
+            data.list[i].loginFlag = Number(data.list[i].loginFlag)
           }
           this.disabled = false
           return data
@@ -115,8 +124,9 @@ export default {
   methods: {
     //  重置
     resetSearchForm () {
-      this.queryParam.productBrandName = ''
-      this.queryParam.enabledFlag = undefined
+      this.queryParam.org.name = ''
+      this.queryParam.loginName = ''
+      this.queryParam.loginFlag = undefined
       this.$refs.table.refresh(true)
     },
     //  新增/编辑
@@ -149,26 +159,27 @@ export default {
         content: '重置密码后,新的密码会以短信形式发送到【管理员手机】,确定要重置吗?',
         centered: true,
         onOk () {
-          // salesDel({ id: row.id }).then(res => {
-          //   if (res.status == 200) {
-          //     _this.$message.success(res.message)
-          //     _this.$refs.table.refresh()
-          //   }
-          // })
+          dealerUserResetP({ id: row.id }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+            }
+          })
         }
       })
     },
-    // 修改状态
-    changeFlagHandle (text, record) {
-      const _data = {
+    // 启用 禁用
+    changeStatus (record) {
+      const params = {
         id: record.id,
-        flag: record.enabledFlag ? '1' : '0'
+        flag: record.loginFlag == 1 ? '0' : '1'
       }
-      updateEnableStatus(_data).then(res => {
+      dealerUserEnable(params).then(res => {
         if (res.status == 200) {
           this.$message.success(res.message)
+          this.$refs.table.refresh()
         } else {
-          record.enabledFlag = !record.enabledFlag
+          this.$refs.table.refresh()
         }
       })
     }

+ 2 - 2
src/views/power/user/updateAreal.vue

@@ -53,7 +53,7 @@ export default {
       other: '',
       form: {
         name: '',
-        subareaSn: ''
+        subareaSn: undefined
       },
       rules: {
         subareaSn: [
@@ -67,7 +67,7 @@ export default {
     setData (row) {
       this.form.id = row.id
       this.form.name = row.name
-      this.form.subareaSn = row.subareaSn || ''
+      this.form.subareaSn = row.subareaSn || undefined
       this.subareaSnBak = row.subareaSn
     },
     onSubmit () {