Blame view

src/views/system/sqywgz/components/djqxsd.vue 8.31 KB
任超 committed
1
<!--
2 3 4
 * @Description: 功能:登记情形设定
 * @Autor: renchao
 * @LastEditTime: 2023-07-19 14:10:04
任超 committed
5 6
-->
<template>
任超 committed
7
  <div class='djqxsd'>
任超 committed
8
    <el-form :model="ruleForm">
任超 committed
9 10 11
      <el-row>
        <el-col :span="5">
          <el-form-item label="登记业务编码">
任超 committed
12
            {{ ruleForm.djywbm }}
任超 committed
13 14
          </el-form-item>
        </el-col>
任超 committed
15 16
        <el-col :span="12">
          <el-form-item label="登记业务名称">
任超 committed
17
            {{ ruleForm.djywmc }}
任超 committed
18 19 20 21
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
任超 committed
22
    <lb-table :column="column" border :key="key" :pagination="false" heightNumSetting :data="tableData">
任超 committed
23 24 25 26
    </lb-table>
  </div>
</template>
<script>
27 28 29 30 31 32 33 34 35 36 37 38
  import { upward, down } from '@/utils/operation'
  export default {
    props: {
      ruleForm: {
        type: Object, default: () => {
          return {}
        }
      },
      djqx: {
        type: Array, default: () => {
          return []
        }
任超 committed
39
      }
40
    },
41 42 43 44 45 46 47 48 49 50 51
    data () {
      return {
        input: '',
        key: 0,
        rules: {
          djywbm: [
            { required: true, message: '登记业务编码', trigger: 'blur' },
          ],
          djywmc: [
            { required: true, message: '登记业务名称', trigger: 'blur' },
          ],
任超 committed
52
        },
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
        column: [
          {
            width: '60',
            renderHeader: (h, scope) => {
              return <i class="el-icon-plus pointer" onClick={() => { this.handleAdd() }} style="color:#409EFF"></i>
            },
            render: (h, scope) => {
              return (
                <i class="el-icon-minus pointer" onClick={() => { this.handleMinus(scope.$index, scope.row) }}></i>
              )
            }
          },
          {
            width: '60',
            label: '序号',
            type: 'index'
          },
          {
            prop: 'nodecode',
            width: '105',
            label: '登记情形编码',
            render: (h, scope) => {
              return (
                <div>
                  <el-input placeholder="登记情形编码" class={{ repeat: scope.row.repeat }} disabled={scope.row.sftsdjqx == '1'}
                    value={scope.row[scope.column.property]}
                    onInput={(val) => { scope.row[scope.column.property] = val }} onBlur={() => { this.nodecodeBlur(scope.$index, scope.row) }} maxlength="8">
                  </el-input>
                </div>
              )
            }
          },
          {
            prop: 'nodename',
            label: '登记情形名称',
            render: (h, scope) => {
              return (
                <div>
                  <el-input placeholder="登记情形名称" disabled={scope.row.sftsdjqx == '1'}
                    value={scope.row[scope.column.property]}
                    onInput={(val) => { scope.row[scope.column.property] = val }}></el-input>
                </div>
              )
            }
          },
          {
            label: '是否启用登记情形',
            width: '140',
            render: (h, scope) => {
              return (
                <el-radio-group v-model={scope.row.enabled} disabled={scope.row.sftsdjqx == '1'} onChange={(val) => { scope.row[scope.column.property] = val }}>
                  <el-radio label={'1'}>启用</el-radio>
                  <el-radio label={'0'}>禁用</el-radio>
                </el-radio-group>
              )
            }
          },
          {
            prop: 'djyy',
            label: '登记原因模板',
            render: (h, scope) => {
              return (
                <div>
                  <el-input placeholder="登记原因模板" disabled={scope.row.sftsdjqx == '1'} value={scope.row[scope.column.property]}
                    onInput={(val) => { scope.row[scope.column.property] = val }}></el-input>
                </div>
119

120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
              )
            }
          },
          {
            label: '是否启用模板',
            width: '140',
            render: (h, scope) => {
              return (
                <el-radio-group v-model={scope.row.sfqydjyymb} disabled={scope.row.sftsdjqx == '1'} onChange={(val) => { scope.row[scope.column.property] = val }}>
                  <el-radio label={'1'}>启用</el-radio>
                  <el-radio label={'0'}>禁用</el-radio>
                </el-radio-group>
              )
            }
          },
          {
            label: '移动',
            width: '100',
            render: (h, scope) => {
              return (
                <div>
                  <el-button type='text' disabled={scope.$index == 0} onClick={() => { this.moveUpward(scope.$index, scope.row) }}>上移</el-button>
                  <el-button type='text' disabled={(scope.$index + 1) == this.tableData.length} onClick={() => { this.moveDown(scope.$index, scope.row) }}>下移</el-button >
                </div>
              )
            }
任超 committed
146
          }
147 148 149 150 151 152 153 154 155 156 157
        ],
        tableData: []
      }
    },
    watch: {
      tableData: {
        handler (newValue, oldValue) {
          let that = this
          if (!_.isEqual(newValue, this.djqx)) {
            let temp = newValue.some((item, index, array) => {
              return item.repeat;
158
            })
159 160 161 162 163 164 165 166 167 168 169
            if (temp) {
              that.$emit('updateValue', {
                djqx: newValue,
                btnDisabled: true
              })
            } else {
              that.$emit('updateValue', {
                djqx: newValue,
                btnDisabled: false
              })
            }
170
          }
171 172
        },
        deep: true
173
      },
174 175 176 177 178 179 180
      djqx: {
        handler: function (newValue) {
          this.tableData = _.cloneDeep(newValue)
          this.addIndexes()
        },
        deep: true
      }
181
    },
182 183
    methods: {
      // 添加索引
yuanbo committed
184 185 186 187 188 189
      /**
       * @description: 添加索引
       * @param {*} data
       * @param {*} isAdd
       * @author: renchao
       */
190 191 192 193 194 195 196
      addIndexes (data = this.tableData, isAdd = true) {
        data.forEach((item, index) => {
          if (isAdd) {
            item.index = index + 1
          }
        })
      },
yuanbo committed
197 198 199 200
      /**
       * @description: handleAdd
       * @author: renchao
       */
201 202 203 204 205 206 207 208 209 210 211 212 213 214
      handleAdd () {
        this.$nextTick(() => {
          let container = this.$el.querySelector('.el-table__body-wrapper');
          container.scrollTop = container.scrollHeight;
        })
        this.tableData.push(
          {
            nodecode: '',
            nodename: '',
            enabled: '1',
            djyy: '',
            sfqydjyymb: '0'
          }
        )
215
        this.addIndexes()
216
        this.key++
任超 committed
217
      },
yuanbo committed
218 219 220 221 222 223
      /**
       * @description: handleMinus
       * @param {*} index
       * @param {*} row
       * @author: renchao
       */
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
      handleMinus (index, row) {
        this.$confirm('此操作将永久删除, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.tableData.splice(index, 1)
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
240
        });
241
      },
yuanbo committed
242 243 244 245 246 247
      /**
       * @description: nodecodeBlur
       * @param {*} index
       * @param {*} row
       * @author: renchao
       */
248 249 250 251 252 253 254 255 256 257 258
      nodecodeBlur (index, row) {
        let list = _.cloneDeep(this.tableData).filter(item => item.bsmSqyw != row.bsmSqyw)
        let arr = list.map(item => item.nodecode)
        if (arr.includes(row.nodecode)) {
          this.$set(row, 'repeat', true)
          this.$message.error('登记情形编码不能重复');
        } else {
          this.$set(row, 'repeat', false)
        }
      },
      // 上移下移
yuanbo committed
259 260 261 262 263 264
      /**
       * @description: 上移下移
       * @param {*} index
       * @param {*} row
       * @author: renchao
       */
265 266 267 268
      moveUpward (index, row) {
        upward(index, this.tableData)
        this.key++
      },
yuanbo committed
269 270 271 272 273 274
      /**
       * @description: moveDown
       * @param {*} index
       * @param {*} row
       * @author: renchao
       */
275 276 277
      moveDown (index, row) {
        down(index, this.tableData)
        this.key++
任超 committed
278 279
      }
    }
任超 committed
280 281
  }
</script>
任超 committed
282
<style lang='scss' scoped>
283 284 285 286 287
  .djqxsd {
    .repeat {
      .el-input__inner {
        border-color: red !important;
      }
任超 committed
288 289
    }
  }
yuanbo committed
290
</style>