按钮级别的新版本,多级别的组织架构
loulijun2021
2023-08-08 bc5d103d58d3c421ae5f95d7cfa71a125e2414fc
1.编码规则完成30%
已添加2个文件
已修改3个文件
643 ■■■■■ 文件已修改
src/api/systemSetting.js 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/styles/global.css 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basicSettings/roleList.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/systemSetting/encodingRules.vue 545 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/systemSetting.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,60 @@
import request from '@/utils/request'
// ç¼–码规则查询
export function EncodingRules(data) {
  return request({
    url: 'SystemSetting/EncodingRules',
    method: 'get',
    params: data
  })
}
// ç¼–码规则编辑保存
export function SaveEncodingRules(data) {
  return request({
    url: 'SystemSetting/SaveEncodingRules',
    method: 'post',
    data
  })
}
export function CodeMenuSelect() {
  return request({
    url: 'SystemSetting/CodeMenuSelect',
    method: 'get'
  })
}
// èŽ·å–è§„åˆ™ç”Ÿæˆçš„ç¼–ç (每次获取最新)
export function NewEncodingRules(data) {
  return request({
    url: 'SystemSetting/NewEncodingRules',
    method: 'get',
    params: data
  })
}
// èŽ·å–è§„åˆ™ç”Ÿæˆçš„ç¼–ç (每次获取最新)
export function OnlyEncodingRules(data) {
  return request({
    url: 'SystemSetting/OnlyEncodingRules',
    method: 'get',
    params: data
  })
}
// å›žå†™è§„则生成的编码(使用保存)
export function SaveOnlyEncodingRules(data) {
  return request({
    url: 'SystemSetting/SaveOnlyEncodingRules',
    method: 'post',
    data
  })
}
// ç”Ÿæˆç‰©æ–™æ ‡ç­¾æ¡ç (每次获取最新,App可使用)
export function LabelBarCode(data) {
  return request({
    url: 'SystemSetting/LabelBarCode',
    method: 'get',
    params: data
  })
}
src/router/index.js
@@ -238,6 +238,24 @@
      }
    ]
  },
  {
    path: '/systemSetting',
    component: Layout,
    redirect: '/systemSetting/encodingRules',
    name: '系统设置',
    code: '1005',
    meta: { code: '1005', title: '系统设置', icon: 'xtsz' },
    alwaysShow: true, // å½“children只有一个时,也显示父菜单
    children: [
      {
        path: 'reportList',
        name: 'reportListCancel',
        code: '1050',
        component: () => import('@/views/systemSetting/encodingRules'),
        meta: { code: '1050', title: '编码规则', icon: '', keepAlive: true }
      }
    ]
  }
]
src/styles/global.css
@@ -23,6 +23,20 @@
  padding: 0 10px;
}
.el-table__body-wrapper{
  background: #f8f8fa;
}
.el-input__inner{
  height: 34px !important;
}
.el-dialog__body{
  padding:50px 80px !important;
}
/*头部按钮组样式*/
.bodyTopButtonGroup {
  /*padding-left: 10px;*/
src/views/basicSettings/roleList.vue
@@ -131,7 +131,7 @@
                    <div v-for="(item,index) in treeCenter[0].children" :key="item.menucode">
                      <div
                        v-if="item.buttoncodelist ===null "
                        v-if="!item.buttoncodelist"
                        style="margin-left: 40px;height:26px;display: flex;"
                      />
@@ -179,7 +179,7 @@
                  <div v-if="treeCenter.length>0">
                    <div v-for="item in treeCenter[0].children" :key="item.menucode">
                      <div
                        v-if="item.datacodelist ===null "
                        v-if="!item.datacodelist"
                        style="margin-left: 40px;height:26px;display: flex;"
                      />
@@ -339,7 +339,7 @@
      this.treeCenter[0].children.forEach(item => {
        if (item.children && item.children.length) {
          item.children.forEach(it => {
            it.buttoncodelist = it.buttoncodelist !== null ? it.buttoncodelist.split(',') : []
            it.buttoncodelist = it.buttoncodelist !== '' && it.buttoncodelist !== null ? it.buttoncodelist.split(',') : []
            if (it.buttoncodelist && it.buttoncodelist.length > 0) {
              it.buttoncodelist = this.$ButtonData.filter(j =>
                it.buttoncodelist.includes(j.buttoncode)
src/views/systemSetting/encodingRules.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,545 @@
<template>
  <div>
    <div class="body" :style="{height:mainHeight+'px'}">
      <div class="bodyTopButtonGroup" style="justify-content: space-between">
        <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
      </div>
      <div class="bodyTopFormGroup">
        <el-form
          ref="form"
          :model="form"
          label-width="100px"
          inline
          style="display: flex;"
        >
          <div class="elForm">
            <el-form-item label="编码名称" style=" display: flex;">
              <el-input v-model="form.rightname" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="固定字符" style=" display: flex;">
              <el-input v-model="form.prefix" placeholder="请输入" style="width: 200px" />
            </el-form-item>
          </div>
          <div class="bodySearchReset" :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}">
            <el-button v-waves type="primary" icon="el-icon-search" @click="search">查询</el-button>
            <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">重置</el-button>
          </div>
        </el-form>
        <div
          class="bodyTopFormExpand"
        >
          <!--          <svg-icon-->
          <!--            v-show="mouseHoverType==='mouseout'"-->
          <!--            style="cursor: pointer"-->
          <!--            :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"-->
          <!--            @mouseenter="mouseHoverType=$event.type"-->
          <!--          />-->
          <!--          <svg-icon-->
          <!--            v-show="mouseHoverType==='mouseenter'"-->
          <!--            style="cursor: pointer"-->
          <!--            :icon-class="!isExpandForm?'doubleDown':'doubleUp'"-->
          <!--            @click="isExpandForm=!isExpandForm"-->
          <!--            @mouseout="mouseHoverType=$event.type"-->
          <!--          />-->
        </div>
      </div>
      <div class="elTableDiv">
        <!--        :row-class-name="tableRowClassName"-->
        <el-table
          ref="tableDataRef"
          class="tableFixed"
          :data="tableData"
          :height="isExpandForm?tableHeight:(tableHeight+40)+'px'"
          border
          :style="{width: 100+'%',height:isExpandForm?tableHeight:(tableHeight+40)+'px',}"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
          @sort-change="sortChange"
        >
          <el-table-column
            prop="RowNum"
            width="50"
            fixed
            label="序号"
          />
          <el-table-column
            prop="org_code"
            label="编码"
            sortable="custom"
          />
          <el-table-column
            prop="org_name"
            label="编码名称"
            sortable="custom"
          />
          <el-table-column
            prop="description"
            label="类型"
            sortable="custom"
          />
          <el-table-column
            prop="parentorg_name"
            label="固定字符"
            sortable="custom"
          />
          <el-table-column
            prop="lm_user"
            label="编码格式"
            sortable="custom"
          />
          <el-table-column
            prop="lm_date"
            label="创建时间"
            width="160"
            sortable="custom"
          />
          <el-table-column
            label="操作"
            width="120"
            fixed="right"
          >
            <template slot-scope="{row}">
              <div class="operationClass">
                <el-tooltip class="item" effect="dark" content="编辑" placement="top">
                  <i class="el-icon-edit-outline" @click="edit('edit',row)" />
                </el-tooltip>
                <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top">
                  <i class="el-icon-delete" @click="del(row)" />
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!--分页-->
      <pagination
        :total="total"
        :page.sync="form.page"
        :limit.sync="form.rows"
        align="right"
        layout="total,prev, pager, next,sizes"
        popper-class="select_bottom"
        @pagination="getEncodingRules"
      />
    </div>
    <el-dialog
      v-el-drag-dialog
      :title="operation==='add'?'新增':'编辑'"
      :visible.sync="dialogVisible"
      width="800px"
      :close-on-click-modal="false"
      top="15vh"
      @closed="handleClose"
      @close="handleClose"
    >
      <el-form
        ref="dialogForm"
        inline
        :rules="dialogFormRules"
        style="display: flex;flex-direction: column"
        :model="dialogForm"
        label-width="80px"
      >
        <el-form-item label="菜单类型" required>
          <el-radio-group v-model="dialogForm.type" @change="radioChange">
            <el-radio label="PC" name="PC" />
            <el-radio label="APP" name="APP" />
          </el-radio-group>
        </el-form-item>
        <el-form-item label="菜单名称" required>
          <el-cascader
            ref="cascader"
            :options="menuOptions"
            filterable
            :props="defaultProps"
            :show-all-levels="false"
          />
        </el-form-item>
        <el-form-item label="固定字符" prop="prefix">
          <el-input v-model="dialogForm.prefix" style="width: 200px" />
        </el-form-item>
        <el-form-item prop="filingdate" label="编码格式">
          <el-select
            v-model="dialogForm.filingdate"
            style="width: 200px"
            placeholder="请选择"
            :popper-append-to-body="false"
          >
            <el-option
              v-for="item in dateType"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="自增位数" prop="incbit" required>
          <el-input v-model="dialogForm.incbit" style="width: 200px" />
        </el-form-item>
        <el-form-item label="编码预览">
          {{ encodingPre }}
          <!--          <el-input v-model="dialogForm.OrgName" style="width: 200px" />-->
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button v-waves @click="dialogVisibleCancel">取 æ¶ˆ</el-button>
          <el-button v-waves type="primary" @click="dialogVisibleConfirm">ç¡® å®š</el-button>
        </div>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination'
import { AddUpdateOrganization, DeleteOrganization, OrganizationSearch, PrentOrganization } from '@/api/basicSettings'
import { getCookie } from '@/utils/auth'
import { validateCode } from '@/utils/global'
import elDragDialog from '@/directive/el-drag-dialog'
import waves from '@/directive/waves'
import { LoginMenu } from '@/api/user'
import { CodeMenuSelect, EncodingRules, SaveEncodingRules } from '@/api/systemSetting'
import arrayToTree from 'array-to-tree'
export default {
  name: 'Zzjg',
  components: {
    Pagination
  },
  directives: { elDragDialog, waves },
  data() {
    return {
      mouseHoverType: 'mouseout',
      isExpandForm: false,
      mainHeight: 0,
      tableHeight: 0,
      form: {
        rightname: '', // ç¼–码名称
        prefix: '', // å›ºå®šå­—符
        prop: 'lm_date', // æŽ’序字段
        order: 'desc', // æŽ’序字段
        page: 1, // ç¬¬å‡ é¡µ
        rows: 20 // æ¯é¡µå¤šå°‘条
      },
      total: 10,
      tableData: [],
      dialogVisible: false,
      dialogForm: {
        type: 'PC', // èœå•类型
        rightcode: '', // èœå•编码
        rightname: '', // èœå•名称
        incbit: '1', // è‡ªå¢žä½æ•°
        filingdate: '', // ç¼–码格式
        prefix: ''// å›ºå®šå­—符
      },
      encodingPre: '', // ç¼–码预览
      dateType: [
        { name: '年月日', code: 'YMD' },
        { name: '年月', code: 'YM' },
        { name: 'å¹´', code: 'Y' }
      ],
      menuOptionsAll: [],
      menuOptions: [],
      defaultProps: {
        expandTrigger: 'hover',
        value: 'menucode',
        label: 'menuname'
      },
      operation: '',
      dialogFormRules: {
        prefix: [
          { required: true, message: '请输入固定字符', trigger: ['blur', 'change'] }
        ],
        // OrgCode: [
        //   { required: true, validator: validateCode, trigger: ['blur', 'change'] }
        // ],
        filingdate: [
          { required: true, message: '请选择编码格式', trigger: ['blur', 'change'] }
        ],
        incbit: [
          { required: true, message: '请输入自增位数', trigger: ['blur', 'change'] }
        ]
      }
    }
  },
  watch: {
    dialogForm: {
      handler(newValue, oldValue) {
        const date = new Date()
        let newDate = ''
        if (newValue.filingdate === 'YMD') {
          newDate = date.getFullYear().toString().substring(2, 4) + '' + (date.getMonth() + 1 + '').padStart(2, '0') + '' + (date.getDate() + '').padStart(2, '0')
        } else if (newValue.filingdate === 'YM') {
          newDate = date.getFullYear().toString().substring(2, 4) + '' + (date.getMonth() + 1 + '').padStart(2, '0')
        } else if (newValue.filingdate === 'Y') {
          newDate = date.getFullYear().toString().substring(2, 4) + ''
        }
        this.encodingPre = newValue.prefix + '' + newDate + '' + (1 + '').padStart(newValue.incbit, '0')
      },
      immediate: true,
      deep: true
    }
  },
  created() {
    this.getEncodingRules()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
    this.getCodeMenuSelect()
  },
  methods: {
    async getCodeMenuSelect() {
      const { data: res } = await CodeMenuSelect()
      this.menuOptionsAll = arrayToTree(res, {
        parentProperty: 'parent_id',
        customID: 'menucode',
        childrenProperty: 'children'
      })
      this.menuOptions = this.menuOptionsAll.filter(i => i.type === this.dialogForm.type)
      console.log(this.menuOptions, 2)
    },
    radioChange() {
      this.menuOptions = this.menuOptionsAll.filter(i => i.type === this.dialogForm.type)
    },
    async getEncodingRules() {
      const res = await EncodingRules(this.form)
      this.tableData = res.data
      this.total = res.count
    },
    // æŽ’序改变时
    sortChange({ column, prop, order }) {
      if (order === 'descending') {
        order = 'desc'
      } else if (order === 'ascending') {
        order = 'asc'
      } else {
        order = 'desc'
      }
      this.form.order = order
      this.form.prop = prop
      this.getEncodingRules()
    },
    // æŸ¥è¯¢
    search() {
      this.getEncodingRules()
    },
    // é‡ç½®
    reset() {
      this.form.rightname = ''
      this.form.prefix = ''
      this.getEncodingRules()
    },
    // æ–°å¢žæŒ‰é’®
    add(operation) {
      this.operation = operation
      this.dialogVisible = true
    },
    // ä¿®æ”¹æŒ‰é’®
    edit(operation, row) {
      this.operation = operation
      this.dialogVisible = true
      this.$nextTick(() => {
        this.dialogForm.OrgCode = row.org_code
        this.dialogForm.OrgName = row.org_name
        this.dialogForm.SupUnit = row.parent_id
      })
    },
    // åˆ é™¤æŒ‰é’®
    async del(row) {
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        DeleteOrganization({ orgid: row.code }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            if (this.form.page > 1 && this.tableData.length === 1) {
              this.form.page--
            }
            this.getEncodingRules()
          }
        })
      }).catch(() => {
        this.$message.info('已取消删除')
      })
    },
    // å¯¹è¯æ¡†å…³é—­äº‹ä»¶
    handleClose() {
      this.dialogForm.rightcode = ''
      this.dialogForm.rightname = ''
      this.dialogForm.incbit = '1'
      this.dialogForm.filingdate = ''
      this.dialogForm.prefix = ''
      this.$refs.cascader.checkedValue = ''
      this.$refs.dialogForm.clearValidate()
    },
    // å¯¹è¯æ¡†å–消
    dialogVisibleCancel() {
      this.dialogVisible = false
    },
    // å¯¹è¯æ¡†ç¡®è®¤
    dialogVisibleConfirm() {
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          const rightcode = this.$refs.cascader.checkedValue[ this.$refs.cascader.checkedValue.length - 1]
          this.dialogForm.rightcode = rightcode
          this.dialogForm.rightname = this.menuOptions[this.menuOptions.findIndex(i => i.menucode === this.$refs.cascader.checkedValue[0])].children.find(i => i.menucode === rightcode).menuname
          SaveEncodingRules(this.dialogForm).then(res => {
            if (res.code === '200') {
              this.$notify.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
              this.dialogVisible = false
              this.getEncodingRules()
            } else {
              this.$notify.error(this.operation === 'add' ? '添加失败!' : '修改失败!')
            }
          })
        }
      })
    },
    // èŽ·å–é¡µé¢é«˜åº¦
    getHeight() {
      this.$nextTick(() => {
        this.mainHeight = window.innerHeight - 85
        this.tableHeight = this.mainHeight - 255
        this.$refs.tableDataRef.doLayout()
      })
    }
    // tableRowClassName({ row, rowIndex }) {
    //   return 'custom-row'
    // }
  }
}
</script>
<!--公共页面样式-->
<!--<style lang="scss" scoped>-->
<!--$main_color: #42b983;-->
<!--::v-deep .el-button&#45;&#45;text{-->
<!--  font-size: 14px ;-->
<!--  cursor: pointer ;-->
<!--}-->
<!--.el-icon-share ,.el-icon-delete,.el-icon-edit-outline{-->
<!--  color: $main_color;-->
<!--  cursor: pointer;-->
<!--}-->
<!--.el-icon-edit-outline{-->
<!--  margin-right: 15px;-->
<!--}-->
<!--::v-deep .el-button&#45;&#45;primary, .el-button&#45;&#45;default, .el-button&#45;&#45;info {-->
<!--  height: 34px;-->
<!--  display: flex;-->
<!--  align-items: center;-->
<!--  padding: 0 15px;-->
<!--}-->
<!--::v-deep .el-button&#45;&#45;primary {-->
<!--  //background-color: $main_color !important;-->
<!--}-->
<!--::v-deep .el-button&#45;&#45;default {-->
<!--  background-color: #f8f8fa;-->
<!--  border: none;-->
<!--}-->
<!--::v-deep .el-input__inner {-->
<!--  height: 34px;-->
<!--  line-height: 34px;-->
<!--  //color: #a7a7a7;-->
<!--}-->
<!--::v-deep .el-dialog__body {-->
<!--  padding: 20px 100px !important;-->
<!--}-->
<!--::v-deep .dialogVisibleRoles .el-dialog__body {-->
<!--  padding: 20px 20px !important;-->
<!--}-->
<!--::v-deep .importPickerClass .el-dialog__body {-->
<!--  padding: 20px 20px !important;-->
<!--}-->
<!--::v-deep .el-dialog__footer {-->
<!--  display: flex;-->
<!--  justify-content: flex-end;-->
<!--}-->
<!--::v-deep .el-table .caret-wrapper {-->
<!--  transform: scale(0.8);-->
<!--}-->
<!--::v-deep .cell {-->
<!--  display: flex;-->
<!--  align-items: center;-->
<!--  justify-content: space-between;-->
<!--}-->
<!--::v-deep .el-table::before {-->
<!--  height: 0;-->
<!--}-->
<!--::v-deep .el-table__body-wrapper {-->
<!--  background-color: #f8f8fa;-->
<!--}-->
<!--::v-deep .el-table__body .el-table__row.hover-row td{-->
<!--  background-color: #eaecef ;-->
<!--}-->
<!--::v-deep .el-form&#45;&#45;inline .el-form-item__label {-->
<!--  color: #a7a7a7;-->
<!--}-->
<!--.body ::v-deep .el-divider {-->
<!--  border: 1px solid #eee;-->
<!--  width: 99%;-->
<!--  margin: 10px auto;-->
<!--}-->
<!--.body ::v-deep .el-form-item {-->
<!--  margin-bottom: 0;-->
<!--}-->
<!--.userDialogVisible ::v-deep .el-form-item {-->
<!--  margin-bottom: 0;-->
<!--}-->
<!--::v-deep .el-select__caret{-->
<!--  display: flex;-->
<!--  align-items: center;-->
<!--  justify-content: center;-->
<!--}-->
<!--.tableFixed{-->
<!--  ::v-deep .el-table__fixed-right{-->
<!--    height: 100% !important;-->
<!--  }-->
<!--  ::v-deep .el-table__fixed{-->
<!--    height: 100% !important;-->
<!--  }-->
<!--}-->
<!--</style>-->
<!--<style>-->
<!--.el-table .custom-row {-->
<!--  background: #f8f8fa;-->
<!--}-->
<!--</style>-->