loulijun2021
2022-06-30 7d0a954d23d21c0cdaff6ed20ad7291b3dbf889a
src/views/xtsz/bmgz.vue
@@ -68,7 +68,7 @@
          />
          <el-table-column
            prop="prefix"
            label="前缀"
            label="固定字符"
            sortable="custom"
          >
            <template slot-scope="{row}">
@@ -132,12 +132,12 @@
    >
      <el-form ref="dialogForm" :rules="dialogFormRules" :model="dialogForm" label-width="80px">
        <el-form-item label="固定字符" prop="OrgName">
          <el-input v-model="dialogForm.OrgName" style="width: 220px" />
        <el-form-item label="固定字符" prop="prefix">
          <el-input v-model="dialogForm.prefix" style="width: 220px" />
        </el-form-item>
        <el-form-item prop="SupUnit" label="提交日期">
        <el-form-item prop="filingdate" label="提交日期">
          <el-select
            v-model="dialogForm.SupUnit"
            v-model="dialogForm.filingdate"
            style="width: 220px"
            placeholder="请选择"
            :popper-append-to-body="false"
@@ -150,12 +150,14 @@
            />
          </el-select>
        </el-form-item>
        <el-form-item label="自增位数" prop="OrgName">
          <el-input v-model="dialogForm.OrgName" style="width: 220px" />
        <el-form-item label="自增位数" prop="incbit">
          <!--          @change="handleChange"-->
          <el-input-number v-model="dialogForm.incbit" :min="1" :max="100" label="描述文字" />
          <!--          <el-input v-model="dialogForm.incbit" style="width: 220px" />-->
        </el-form-item>
        <el-form-item label="编码预览">
          <!--          <el-input v-model="dialogForm.OrgName" style="width: 220px" />-->
          xxxx
          {{ encodingPre }}
        </el-form-item>
      </el-form>
@@ -171,9 +173,7 @@
<script>
import Pagination from '@/components/Pagination'
import { AddUpdateOrganization, DeleteOrganization, OrganizationSearch, PrentOrganization } from '@/api/jcsz'
import { getCookie } from '@/utils/auth'
import { EncodingRules } from '@/api/xtsz'
import { EncodingRules, SaveEncodingRules } from '@/api/xtsz'
const SER_HZ = /^[\u4e00-\u9fa5]+$/
export default {
@@ -205,30 +205,50 @@
        rows: 20 // 每页多少条
      },
      dateType: [
        { label: '年', value: 'Y' },
        { label: '月', value: 'M' },
        { label: '日', value: 'D' }
        { label: '年月日', value: 'YMD' },
        { label: '年月', value: 'YM' },
        { label: '年', value: 'Y' }
      ],
      total: 10,
      tableData: [],
      dialogVisible: false,
      dialogForm: {
        OrgType: '',
        OrgCode: '',
        OrgName: '',
        SupUnit: ''// 上级单位
        rightcode: '', // 功能编码
        rightname: '', // 功能名称
        prefix: '', // 固定字符
        filingdate: '', // 提交日期
        incbit: '' // 自增位数
      },
      operation: '',
      encodingPre: '', // 编码预览
      dialogFormRules: {
        // OrgCode: [
        //   { required: true, validator: validateName, trigger: ['blur', 'change'] }
        // ],
        OrgName: [
          { required: true, message: '请输入名称', trigger: ['blur', 'change'] }
        ]
        // OrgName: [
        //   { required: true, message: '请输入名称', trigger: ['blur', 'change'] }
        // ]
      }
    }
  },
  watch: {
    dialogForm: {
      handler(newVlaue, oldValue) {
        const date = new Date()
        let newDate = ''
        if (newVlaue.filingdate === 'YMD') {
          newDate = date.getFullYear() + '' + (date.getMonth() + 1 + '').padStart(2, '0') + '' + (date.getDate() + '').padStart(2, '0')
        } else if (newVlaue.filingdate === 'YM') {
          newDate = date.getFullYear() + '' + (date.getMonth() + 1 + '').padStart(2, '0')
        } else if (newVlaue.filingdate === 'Y') {
          newDate = date.getFullYear() + ''
        }
        this.encodingPre = newVlaue.prefix + '' + newDate + '' + (1 + '').padStart(newVlaue.incbit, '0')
      },
      immediate: true,
      deep: true
    }
  },
  created() {
@@ -243,10 +263,6 @@
      const res = await EncodingRules(this.form)
      this.tableData = res.data
      this.total = res.count
      // this.tableData = [
      //   { code: 123, name: 'xxx1' }
      // ]
      // this.total = 10
    },
    // 排序改变时
    sortChange({ column, prop, order }) {
@@ -270,10 +286,8 @@
    },
    // 重置
    reset() {
      this.form.OrgCode = ''
      this.form.OrgName = ''
      this.form.OrgType = ''
      this.form.UserName = ''
      this.form.rightname = ''
      this.form.prefix = ''
      this.getEncodingRules()
    },
@@ -288,34 +302,37 @@
      this.dialogVisible = true
      this.$nextTick(() => {
        this.dialogForm.OrgCode = row.org_code
        this.dialogForm.OrgName = row.org_name
        this.dialogForm.SupUnit = row.parent_id
        this.dialogForm.rightcode = row.right_code
        this.dialogForm.rightname = row.right_name
        this.dialogForm.filingdate = this.dateType.find(item => item.label === row.filingdate).value
        this.dialogForm.incbit = row.incbit
        this.dialogForm.prefix = row.prefix
      })
    },
    // 删除按钮
    async del(row) {
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        DeleteOrganization({ orgid: row.code }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            this.getEncodingRules()
          }
        })
      }).catch(() => {
        this.$message.info('已取消删除')
      })
      // this.$confirm('是否确认删除?', '提示', {
      //   confirmButtonText: '确定',
      //   cancelButtonText: '取消',
      //   type: 'warning'
      // }).then(() => {
      //   DeleteOrganization({ orgid: row.code }).then(res => {
      //     if (res.code === '200') {
      //       this.$message.success('删除成功!')
      //       this.getEncodingRules()
      //     }
      //   })
      // }).catch(() => {
      //   this.$message.info('已取消删除')
      // })
    },
    // 对话框关闭事件
    handleClose() {
      this.dialogForm.OrgType = ''
      this.dialogForm.OrgCode = ''
      this.dialogForm.OrgName = ''
      this.dialogForm.SupUnit = ''
      this.dialogForm.rightcode = ''
      this.dialogForm.rightname = ''
      this.dialogForm.filingdate = ''
      this.dialogForm.incbit = ''
      this.dialogForm.prefix = ''
      this.$refs.dialogForm.clearValidate()
    },
    // 对话框取消
@@ -327,12 +344,15 @@
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          const data = {
            OrganCode: this.dialogForm.OrgCode,
            OrganName: this.dialogForm.OrgName,
            OperType: this.operation === 'add' ? 'Add' : 'Update',
            Operator: getCookie('admin')
            rightcode: this.dialogForm.rightcode,
            rightname: this.dialogForm.rightname,
            incbit: this.dialogForm.incbit,
            // filingdate: this.dialogForm.filingdate,
            filingdate: this.dateType.find(item => item.value === this.dialogForm.filingdate).label,
            prefix: this.dialogForm.prefix
          }
          AddUpdateOrganization(data).then(res => {
          console.log(data)
          SaveEncodingRules(data).then(res => {
            if (res.code === '200') {
              this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
              this.dialogVisible = false
@@ -366,9 +386,11 @@
  border: none;
  padding: 0 20px;
}
::v-deep .el-button--primary:hover {
  border: none;
}
::v-deep .el-button--info {
  height: 30px;
  display: flex;
@@ -424,6 +446,7 @@
  height: 30px;
  line-height: 30px;
}
::v-deep .el-input__inner:focus {
  border-color: $main_color;
}
@@ -500,18 +523,28 @@
  border-color: $main_color;
}
::v-deep .el-select .el-input__inner:focus{
::v-deep .el-select .el-input__inner:focus {
  border-color: $main_color;
}
::v-deep .el-select-dropdown__item.selected{
::v-deep .el-select-dropdown__item.selected {
  color: $main_color;
}
::v-deep .el-checkbox__inner:hover{
::v-deep .el-checkbox__inner:hover {
  border-color: $main_color;
}
::v-deep .el-textarea__inner:focus{
::v-deep .el-textarea__inner:focus {
  border-color: $main_color;
}
::v-deep .el-input-number__decrease,::v-deep .el-input-number__increase {
  background-color: $main_color;
  color: #FFFFFF;
  line-height: 31px;
  height: 31px;
  margin-top: 3px;
}
</style>