cloudroam
2024-12-06 78a2c4c89654d905e8578a0a94b103224b5cc777
add: 供应商子账号
已添加2个文件
305 ■■■■■ 文件已修改
pages/log/operation-record.vue 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/supplier/sub-list.vue 228 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/log/operation-record.vue
对比新文件
@@ -0,0 +1,77 @@
<template>
  <el-bus-crud ref="crud" v-bind="tableConfig" />
</template>
<script>
export default {
  data() {
    return {
      tableConfig: {
        url: 'flower/api/operationRecord/list',
        dialogNeedRequest: true,
        persistSelection: true,
        hasOperation: false,
        hasNew: false,
        columns: [
          { label: '页面', prop: 'moduleName' },
          { label: '动作', prop: 'function' },
          { label: '操作人', prop: 'createName' },
          { label: '操作时间', prop: 'createTime' },
          { label: 'IP地址', prop: 'ipAddress' },
          { label: '操作内容', prop: 'content' },
        ],
        searchForm: [
          {
            type: 'row',
            items: [
              {
                label: '页面',
                id: 'module',
                type: 'bus-select-dict',
                el: {
                  code: 'OPERATION_RECORD_MODULE',
                  style: 'width:100%',
                },
              },
              { label: '动作', id: 'function', type: 'input' },
              { label: '操作人', id: 'createName', type: 'input' },
              { label: '操作内容', id: 'content', type: 'input', width: 500 },
              {
                label: '创建日期',
                id: 'createDateBeginStr',
                component: 'el-bus-date-range',
                commonFormat: true,
                commonFormatProps: ['createDateBeginStr', 'createDateEndStr'],
                customClass: 'in-bus-form',
              },
            ],
          },
        ],
        form: [],
        extraButtons: [],
        headerButtons: [],
      },
    }
  },
  head() {
    return {
      title: '操作日志',
    }
  },
}
</script>
<style lang="scss" scoped>
::v-deep {
  .el-upload {
    &-list__item {
      width: 345px;
      height: 128px;
    }
    &.el-upload--picture-card {
      width: 345px;
      height: 128px;
    }
  }
}
</style>
pages/supplier/sub-list.vue
对比新文件
@@ -0,0 +1,228 @@
<template>
  <el-bus-crud ref="crud" v-bind="tableConfig" />
</template>
<script>
export default {
  data() {
    return {
      tableConfig: {
        url: 'flower/api/supplierSub/page',
        editUrl: 'flower/api/supplierSub/addOrUpdate',
        deleteUrl: 'flower/api/supplierSub/delete',
        deleteOnPath: true,
        deleteMethodType: 'post',
        hasNew: false,
        hasDelete: true,
        operationAttrs: {
          width: '200px',
          fixed: 'right',
        },
        columns: [
          { label: '序号', type: 'index' },
          { label: '供应商ID', prop: 'supplierId', minWidth: '120px' },
          {
            label: '供应商名称',
            prop: 'supplierName',
            minWidth: '120px',
          },
          { label: '供应商联系人', prop: 'contactName', minWidth: '100px' },
          { label: '主账号手机号', prop: 'contactTel', minWidth: '120px' },
          { label: '子账号手机号', prop: 'phone', minWidth: '120px' },
          { label: '子账号名', prop: 'name', minWidth: '120px' },
          { label: '子账号联系人', prop: 'contact', minWidth: '120px' },
          { label: '创建时间', prop: 'createTime', minWidth: '120px' },
          {
            label: '启用/禁用',
            formatter: (row) => (
              <el-switch
                value={row.isEnabled}
                onChange={this.onEnabledChange.bind(this, row)}
              ></el-switch>
            ),
            minWidth: 120,
            fixed: 'right',
          },
        ],
        searchForm: [
          {
            type: 'row',
            items: [
              {
                label: '供应商ID', id: 'supplierId', type: 'input',
                rules: {
                  required: false,
                  pattern: /^\d*$/,
                  message: '请输入合法的供应商ID',
                  trigger: 'blur',
                },
              },
              { label: '供应商名称', id: 'supplierName', type: 'input' },
              { label: '主账号手机号', id: 'supplierPhone', type: 'input',
                rules: {
                  required: false,
                  pattern: this.$elBusUtil.REG.MOBILEPHONE,
                  message: '请输入合法的手机号',
                  trigger: 'blur',
                },
              },
              { label: '子账号手机号', id: 'phone', type: 'input',
                rules: {
                  required: false,
                  pattern: this.$elBusUtil.REG.MOBILEPHONE,
                  message: '请输入合法的手机号',
                  trigger: 'blur',
                },
              },
              {
                label: '启用/禁用',
                id: 'isEnabled',
                type: 'bus-select-dict',
                default: '1',
                el: {
                  code: 'USER_ENABLED_OR_DISABLED',
                  clearable: true,
                  style: 'width:100%',
                },
              },
            ],
          },
        ],
        form: [
          {
            label: '供应商ID:',
            id: 'supplierId',
            type: 'input',
            span: 12,
            hidden: (row, item, mode) => mode !== 'view',
          },
          {
            label: '供应商名称:',
            id: 'supplierName',
            type: 'input',
            span: 12,
            hidden: (row, item, mode) => mode !== 'view',
          },
          {
            label: '供应商联系人:',
            id: 'contactName',
            type: 'input',
            span: 12,
            hidden: (row, item, mode) => mode !== 'view',
          },
          {
            label: '主账号手机号:',
            id: 'contactTel',
            type: 'input',
            span: 12,
            hidden: (row, item, mode) => mode !== 'view',
          },
          {
            type: 'row',
            span: 12,
            items: [
              {
                label: '子账号手机号:',
                id: 'phone',
                type: 'input',
                rules: {
                  required: true,
                  pattern: this.$elBusUtil.REG.MOBILEPHONE,
                  message: '请输入合法的手机号',
                  trigger: 'blur',
                },
              },
              {
                label: '子账号名:',
                id: 'name',
                type: 'input',
                rules: {
                  required: true,
                  message: '请输入子账号名',
                  trigger: 'blur',
                },
              },
              {
                label: '子账号联系人:',
                id: 'contact',
                type: 'input',
                rules: {
                  required: true,
                  message: '请输入子账号联系人',
                  trigger: 'blur',
                },
              },
            ],
          },
        ],
        extraButtons: [
          {
            text: '密码修改',
            atClick: (row) => {
              this.$refs.crud.$refs.extraDialog[0].show(row)
              return false
            },
          },
        ],
        extraDialogs: [
          {
            title: '密码修改',
            hiddenReverseItems: [],
            form: [
              {
                label: '请输入新密码:',
                id: 'password',
                type: 'input',
                rules: {
                  required: true,
                  pattern:   /^(?:(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])(?=\S*[-_!@#$%^&*? ]))\S{8,20}$/,
                  message: '请输入正确的密码(8-20位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符)',
                  trigger: 'blur',
                },
              },
            ],
            atConfirm: async (val) => {
              const { code } = await this.$elBusHttp.request(
                'flower/api/supplierSub/addOrUpdate',
                {
                  method: 'post',
                  data: val,
                }
              )
              if (code === 0) {
                this.$message.success('操作成功')
              }
            },
          },
        ],
      },
    }
  },
  head() {
    return {
      title: '子账号列表',
    }
  },
  methods: {
    onEnabledChange(row, e) {
      const url = 'flower/api/supplierSub/page/isEnable'
      const text = e ? '启用' : '禁用'
      this.$elBusUtil
        .confirm(`确定要${text}这个供应商吗?`)
        .then(async () => {
          const { code } = await this.$elBusHttp.request(url, {
            params: {
              id: row.id,
            },
          })
          if (code === 0) {
            this.$message.success(`${text}成功`)
            this.$refs.crud.getList()
          }
        })
        .catch(() => {})
    },
  },
}
</script>