소스 검색

代码提交:
0906系统管理-编号模板管理

sunruiqi 2 년 전
부모
커밋
3c5624ad7e

+ 8 - 0
src/api/sys/OfficeService.js

@@ -32,4 +32,12 @@ export default class OfficeService {
       params: params
     })
   }
+
+  treeData2 (params) {
+    return request({
+      url: '/sys/office/treeData2',
+      method: 'get',
+      params: params
+    })
+  }
 }

+ 35 - 0
src/api/sys/SerialnumTplService.js

@@ -0,0 +1,35 @@
+import request from '@/utils/httpRequest'
+
+export default class SerialnumTplService {
+  list (param) {
+    return request({
+      url: `/sys/template/list`,
+      method: 'get',
+      params: param
+    })
+  }
+
+  remove (url) {
+    return request({
+      url: '/sys/template/remove',
+      method: 'get',
+      params: {id: url}
+    })
+  }
+
+  findById (id) {
+    return request({
+      url: '/sys/template/findById',
+      method: 'get',
+      params: {id: id}
+    })
+  }
+
+  save (param) {
+    return request({
+      url: '/sys/template/save',
+      method: 'post',
+      data: param
+    })
+  }
+}

+ 397 - 0
src/views/modules/sys/mould/SerialnumTplForm.vue

@@ -0,0 +1,397 @@
+<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
+  <div>
+    <el-dialog
+      :title="title"
+      :close-on-click-modal="false"
+      v-dialogDrag
+      width="1200px"
+      @close="close()"
+      @keyup.enter.native="doSubmit"
+      :visible.sync="visible">
+      <el-form size="middle" :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="method==='view'"
+               label-width="150px">
+        <el-row  :gutter="0">
+          <el-col :span="12">
+            <el-form-item label="模板名称" prop="tplName" :rules="[
+                  {required: true, message:'请输入模板名称', trigger:'blur'}
+                ]">
+              <el-input v-model="inputForm.tplName" placeholder="请输入模板名称"></el-input>
+            </el-form-item>
+          </el-col>
+
+          <el-col :span="12">
+            <el-form-item label="公司" prop="companyId"
+                          :rules="[
+                   {required: true, message:'请选择公司', trigger:'blur'}
+                 ]">
+              <SelectTree
+                ref="officeTree"
+                :props="{
+                    value: 'id',             // ID字段名
+                    label: 'name',         // 显示名称
+                    children: 'children'    // 子级字段名
+                  }"
+                :url="`/sys/office/treeData2?type=1`"
+                :value="inputForm.companyId"
+                :clearable="true"
+                :accordion="true"
+                @getValue="(value) => {inputForm.companyId=value}"/>
+            </el-form-item>
+          </el-col>
+
+          <el-col :span="12">
+            <el-form-item label="业务标识" prop="bizCode"
+                          :rules="[
+                      {required: true, message:'请选择业务标识', trigger:'blur'}
+                   ]">
+              <el-select v-model="inputForm.bizCode" placeholder="请选择业务标识" style="width:100%;">
+                <el-option
+                  v-for="item in $dictUtils.getDictList('serial_biztype')"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value">
+                </el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+
+          <el-col :span="12">
+            <el-form-item label="起始序列号" prop="serialNum">
+              <el-input v-model="inputForm.serialNum" placeholder="请输入起始序列号"></el-input>
+            </el-form-item>
+          </el-col>
+
+          <el-col :span="12">
+            <el-form-item label="序列号长度" prop="serialNumLen"
+                          :rules="[
+                   {required: true, message:'请输入序列号长度', trigger:'blur'}
+                 ]">
+              <el-input v-model="inputForm.serialNumLen" placeholder="请输入序列号长度"></el-input>
+            </el-form-item>
+          </el-col>
+
+          <el-col :span="12">
+            <el-form-item label="编号模板" prop="serialTpl"
+                :rules="[
+                  {required: true, message:'请输入编号模板', trigger:'blur'}
+                ]">
+              <el-input v-model="inputForm.serialTpl" :disabled="true" placeholder="请输入编号模板"></el-input>
+            </el-form-item>
+          </el-col>
+
+          <el-col :span="12">
+            <el-form-item label="编号示例" prop="serialTplEx"
+                          :rules="[
+                  {required: true, message:'请输入编号示例', trigger:'blur'}
+                ]">
+              <el-input v-model="inputForm.serialTplEx" :disabled="true" placeholder="请输入编号示例"></el-input>
+            </el-form-item>
+          </el-col>
+
+        </el-row>
+
+        <el-row></el-row>
+          <el-form-item style="margin-top: 20px" label="生成编号模板" prop="mouldList">
+            <vxe-toolbar >
+              <template #buttons>
+                <vxe-button status="primary" size="mini" @click="insertEvent">新增</vxe-button>
+              </template>
+            </vxe-toolbar>
+          </el-form-item>
+
+        <vxe-table
+          border
+          show-overflow
+          ref="xTable"
+          class="vxe-table-element"
+          :data="mouldList"
+          :disabled="method==='view'"
+          style="margin-left: 5em"
+          @cell-click="dbclickFun"
+          @edit-closed=""
+          highlight-current-row
+          :edit-config="{trigger: 'click', mode: 'cell', showStatus: true, autoClear: true}"
+        >
+
+          <vxe-table-column field="type" title="变量名称" :edit-render="{name: '$select', options: $dictUtils.getDictList('variable_type')}">
+            <template v-slot:edit="scope" >
+              <vxe-select v-model="scope.row.type" @input="variableValue(scope.row, scope.row.type)" transfer>
+                <vxe-option
+                  v-for="item in $dictUtils.getDictList('variable_type')"
+                  :key="item.value"
+                  :value="item.value"
+                  :label="item.label">
+                </vxe-option>
+              </vxe-select>
+            </template>
+          </vxe-table-column>
+          <vxe-table-column field="value" title="变量值" :edit-render="{}">
+            <template v-slot:edit="scope">
+              <el-input :disabled="scope.row.showType" v-model="scope.row.value" ></el-input>
+            </template>
+          </vxe-table-column>
+          <vxe-table-column title="操作" width="100">
+            <template v-slot="scope">
+              <el-button size="mini" type="danger" @click="removeEvent(scope.row,scope.$rowIndex)">删除</el-button>
+            </template>
+          </vxe-table-column>
+        </vxe-table>
+
+      </el-form>
+
+        <span slot="footer" class="dialog-footer">
+          <el-button size="small" type="primary" v-if="method != 'view'" @click="generateTemplate()" icon="el-icon-edit-outline">生成模板</el-button>
+          <el-button size="small" @click="close()" icon="el-icon-circle-close">关闭</el-button>
+          <el-button size="small" type="primary" v-if="method != 'view'" @click="doSubmit()" icon="el-icon-circle-check" v-noMoreClick>确定</el-button>
+        </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+  import SerialnumTplService from '@/api/sys/SerialnumTplService'
+  import SelectTree from '@/components/treeSelect/treeSelect.vue'
+  export default {
+    data () {
+      return {
+        visable: false,
+        gridData: [],
+        radio: 0,
+        tableData: [],
+        dataList: [],
+        dataListNew: [],
+        title: '',
+        method: '',
+        isSubmit: false,
+        visible: false,
+        loading: false,
+        returnForm: {
+          id: '',
+          tplName: '',
+          companyId: '',
+          bizCode: '',
+          serialNum: '',
+          serialNumLen: '',
+          serialTpl: '',
+          serialTplEx: ''
+        },
+        inputForm: {
+          id: '',
+          tplName: '',
+          companyId: '',
+          bizCode: '',
+          serialNum: '',
+          serialNumLen: '',
+          serialTpl: '',
+          serialTplEx: ''
+        },
+        mouldList: [],
+        mould: {
+          type: '',
+          value: '',
+          showType: false
+        }
+      }
+    },
+    components: {
+      SelectTree
+    },
+    serialnumTplService: null,
+    created () {
+      this.serialnumTplService = new SerialnumTplService()
+    },
+    methods: {
+      init (method, id) {
+        this.method = method
+        this.inputForm = {
+          id: '',
+          tplName: '',
+          companyId: '',
+          bizCode: '',
+          serialNum: '',
+          serialNumLen: '',
+          serialTpl: '',
+          serialTplEx: '',
+          mouldList: [],
+          mould: {
+            type: '',
+            value: ''
+          }
+        }
+        this.inputForm.id = id
+        if (method === 'add') {
+          this.title = `新建基本信息`
+        } else if (method === 'edit') {
+          this.title = '修改基本信息'
+        } else if (method === 'view') {
+          this.showVi = false
+          this.title = '查看基本信息'
+        }
+        this.visible = true
+        this.loading = false
+        this.$nextTick(() => {
+          this.$refs.inputForm.resetFields()
+          if (method === 'edit' || method === 'view') { // 修改或者查看
+            this.loading = true
+            this.serialnumTplService.findById(this.inputForm.id).then(({data}) => {
+              this.inputForm = data
+            })
+          }
+          this.loading = false
+        })
+      },
+      // 表单提交
+      doSubmit () {
+        this.serialnumTplService.save(this.inputForm).then(({data}) => {
+          this.close()
+          this.$message.success(data)
+          this.$emit('refreshDataList')
+          this.loading = false
+        }).catch(() => {
+          this.loading = false
+        })
+      },
+      close () {
+        this.$refs.inputForm.resetFields()
+        this.visible = false
+        this.showVi = true
+        this.mouldList = []
+      },
+      // 排序
+      sortChangeHandle (column) {
+        this.orders = []
+        if (column.order != null) {
+          this.orders.push({column: this.$utils.toLine(column.prop), asc: column.order === 'ascending'})
+        }
+        this.refreshList()
+      },
+      deleteMsgById (row, index) {
+        this.dataListNew.splice(index, 1)
+        if (row.id !== null && row.id !== '' && row.id !== undefined) {
+          this.ossService.deleteMsgById(row.id)
+        }
+      },
+      tableRowClassName ({row, rowIndex}) {
+        row.index = rowIndex
+      },
+      handleRadioChange (val) {
+        if (val) {
+          this.radio = val.index
+        }
+      },
+      // 点击修改
+      dbclickFun (cell) {
+        this.onedit = false
+      },
+      // 新增
+      async insertEvent () {
+        if (this.inputForm.companyId === undefined || this.inputForm.companyId === '' || this.inputForm.companyId === null) {
+          this.$message.error('请选择公司信息')
+        } else if (this.inputForm.serialNumLen === undefined || this.inputForm.serialNumLen === '' || this.inputForm.serialNumLen === null) {
+          this.$message.error('请输入序列号长度')
+        } else {
+          await this.$refs.xTable.insert().then((data) => {
+            this.mouldList.push(data)
+          })
+        }
+      },
+      // 删除
+      removeEvent (row, rowIndex) {
+        this.$refs.xTable.remove(row)
+        this.mouldList.splice(rowIndex, 1)
+      },
+      // 变量值处理
+      variableValue (row, type) {
+        if (type === '1' || type === '2') {
+          row.showType = true
+        }
+        if (type === '7') {
+          row.value = new Date().getFullYear()
+          row.showType = true
+        }
+        if (type === '8') {
+          let len = this.inputForm.serialNumLen
+          let s = '0000000000000000'
+          s = s.substring(0, len - 1)
+          row.value = s + '1'
+          row.showType = true
+        }
+        if (type === '9') {
+          row.value = new Date().getMonth() + 1
+          row.showType = true
+        }
+      },
+      // 生成模板
+      generateTemplate () {
+        let list = this.mouldList
+        let i = ''
+        let j = ''
+        list.forEach(obj => {
+          // 公司简称
+          if (obj.type === '1') {
+            i = i + '{spnm}'
+          }
+          // 分公司简称
+          if (obj.type === '2') {
+            i = i + '{brspnm}'
+          }
+          // 固定字符、业务类型、业务类型代码、业务类型的字
+          if (obj.type === '3' || obj.type === '4' || obj.type === '5' || obj.type === '6') {
+            i = i + obj.value
+            j = j + obj.value
+          }
+          // 年度
+          if (obj.type === '7') {
+            i = i + '{year}'
+            j = j + obj.value
+          }
+          // 流水号
+          if (obj.type === '8') {
+            i = i + '{serialNum}'
+            j = j + obj.value
+          }
+          // 月度
+          if (obj.type === '9') {
+            i = i + '{month}'
+            j = j + obj.value
+          }
+        })
+        this.inputForm.serialTpl = i
+        this.inputForm.serialTplEx = j
+      }
+    }
+  }
+</script>
+
+<style>
+  .tid_40 .vxe-body--column .vxe-cell{
+    padding: 1px;
+    text-align: center;
+  }
+  .tid_40 .vxe-header--row .col--last{
+    text-align: center;
+  }
+  .tid_45 .vxe-body--column .vxe-cell{
+    padding: 1px;
+    text-align: center;
+  }
+  .tid_45 .vxe-header--row .col--last{
+    text-align: center;
+  }
+  .vxe-select--panel {
+    z-index: 9997 !important
+  }
+  .vxe-input--panel.type--date, .vxe-input--panel.type--month, .vxe-input--panel.type--week, .vxe-input--panel.type--year {
+    z-index: 9998 !important
+  }
+</style>
+
+<style scoped>
+  .avatar{
+    height: 100px;
+  }
+  .el-divider__text {
+    font-weight: bold;
+    font-size: 16px;
+  }
+</style>

+ 180 - 0
src/views/modules/sys/mould/SerialnumTplList.vue

@@ -0,0 +1,180 @@
+<template>
+  <div class="page">
+      <el-form size="small" :inline="true" class="query-form" ref="searchForm" :model="searchForm" @keyup.enter.native="refreshList()" @submit.native.prevent>
+            <!-- 搜索框-->
+         <el-form-item label="模板名称" prop="tplName">
+                <el-input size="small" v-model="searchForm.tplName" placeholder="请输入模板名称" clearable></el-input>
+         </el-form-item>
+
+          <el-form-item>
+            <el-button type="primary" @click="refreshList()" size="small" icon="el-icon-search">查询</el-button>
+            <el-button @click="resetSearch()" size="small" icon="el-icon-refresh-right">重置</el-button>
+          </el-form-item>
+      </el-form>
+
+     <div class="bg-white top">
+        <vxe-toolbar :refresh="{query: refreshList}" import export print custom>
+          <template #buttons>
+            <el-button v-if="hasPermission('sys:serialnumTpl:add')" type="primary" size="small" icon="el-icon-plus" @click="add()">新建</el-button>
+          </template>
+        </vxe-toolbar>
+        <div style="height: calc(100% - 80px);">
+            <vxe-table
+                border="inner"
+                auto-resize
+                resizable
+                height="auto"
+                :loading="loading"
+                size="small"
+                ref="serialnumTplTable"
+                show-header-overflow
+                show-overflow
+                highlight-hover-row
+                :menu-config="{}"
+                :print-config="{}"
+                @sort-change="sortChangeHandle"
+                :sort-config="{remote:true}"
+                :data="dataList"
+                :checkbox-config="{}">
+                <vxe-column type="seq" width="40"></vxe-column>
+                <vxe-column type="checkbox"  width="40px"></vxe-column>
+                <vxe-column width="300px"  title="模板名称" field="tplName">
+                    <template slot-scope="scope">
+                        <el-link  type="primary" :underline="false" @click="view(scope.row.id)">{{scope.row.tplName}}</el-link>
+                    </template>
+                </vxe-column>
+                <vxe-column width="200px"  title="公司名称" field="companyName" ></vxe-column>
+                <vxe-column width="100px"  title="业务标识" field="bizCode" >
+                  <template slot-scope="scope">
+                    {{ $dictUtils.getDictLabel("serial_biztype", scope.row.bizCode, '-') }}
+                  </template>
+                </vxe-column>
+                <vxe-column width="100px"  title="序列号长度" field="serialNumLen" ></vxe-column>
+                <vxe-column width="200px" title="编号模板示例" field="serialTplEx" > </vxe-column>
+
+                <vxe-column title="操作" width="200px" fixed="right" align="center">
+                    <template  slot-scope="scope">
+                      <el-button v-if="hasPermission('sys:serialnumTpl:view')" type="text" icon="el-icon-view" size="small" @click="view(scope.row.id)">查看</el-button>
+                      <el-button v-if="hasPermission('sys:serialnumTpl:edit') " type="text" icon="el-icon-edit" size="small" @click="edit(scope.row.id)">修改</el-button>
+                      <el-button v-if="hasPermission('sys:serialnumTpl:del') " type="text"  icon="el-icon-delete" size="small" @click="del(scope.row.id)">删除</el-button>
+                    </template>
+                </vxe-column>
+            </vxe-table>
+          <vxe-pager
+            background
+            size="small"
+            :current-page="tablePage.currentPage"
+            :page-size="tablePage.pageSize"
+            :total="tablePage.total"
+            :page-sizes="[10, 20, 100, 1000, {label: '全量数据', value: 1000000}]"
+            :layouts="['PrevPage', 'JumpNumber', 'NextPage', 'FullJump', 'Sizes', 'Total']"
+            @page-change="currentChangeHandle">
+          </vxe-pager>
+        </div>
+     </div>
+        <!-- 弹窗, 新增 / 修改 -->
+    <SerialnumTplForm  ref="serialnumTplForm" @refreshDataList="refreshList"></SerialnumTplForm>
+  </div>
+</template>
+
+<script>
+  import SerialnumTplForm from './SerialnumTplForm'
+  import SerialnumTplService from '@/api/sys/SerialnumTplService'
+  export default {
+    data () {
+      return {
+        visible: false,
+        searchForm: {
+          tplName: ''
+        },
+        dataList: [],
+        tablePage: {
+          total: 0,
+          currentPage: 1,
+          pageSize: 10,
+          orders: []
+        },
+        loading: false
+      }
+    },
+    serialnumTplService: null,
+    created () {
+      this.serialnumTplService = new SerialnumTplService()
+    },
+    components: {
+      SerialnumTplForm
+    },
+    activated () {
+      this.refreshList()
+    },
+
+    methods: {
+      // 获取数据列表
+      refreshList () {
+        this.loading = true
+        this.serialnumTplService.list({
+          'current': this.tablePage.currentPage,
+          'size': this.tablePage.pageSize,
+          'orders': this.tablePage.orders,
+          'itemType': '1',
+          ...this.searchForm
+        }).then(({data}) => {
+          this.dataList = data.records
+          this.tablePage.total = data.total
+          this.loading = false
+        })
+      },
+      // 当前页
+      currentChangeHandle ({currentPage, pageSize}) {
+        this.tablePage.currentPage = currentPage
+        this.tablePage.pageSize = pageSize
+        this.refreshList()
+      },
+      // 排序
+      sortChangeHandle (column) {
+        this.tablePage.orders = []
+        if (column.order != null) {
+          this.tablePage.orders.push({column: this.$utils.toLine(column.property), asc: column.order === 'asc'})
+        }
+        this.refreshList()
+      },
+      // 新增
+      add () {
+        this.$refs.serialnumTplForm.init('add', '')
+      },
+      // 修改
+      edit (id) {
+        id = id || this.$refs.serialnumTplTable.getCheckboxRecords().map(item => {
+          return item.id
+        })[0]
+        this.$refs.serialnumTplForm.init('edit', id)
+      },
+      // 查看
+      view (id) {
+        this.$refs.serialnumTplForm.init('view', id)
+      },
+      // 删除
+      del (id) {
+        let ids = id || this.$refs.serialnumTplTable.getCheckboxRecords().map(item => {
+          return item.id
+        }).join(',')
+        this.$confirm(`确定删除所选项吗?`, '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          this.loading = true
+          this.serialnumTplService.remove(ids).then(({data}) => {
+            this.$message.success(data)
+            this.refreshList()
+            this.loading = false
+          })
+        })
+      },
+      resetSearch () {
+        this.$refs.searchForm.resetFields()
+        this.refreshList()
+      }
+    }
+  }
+</script>