Blame view

src/views/zsgl/zsrk/components/addDialog.vue 10 KB
蔡俊立 committed
1
<template>
2 3 4 5 6
  <el-form ref="ruleForm" :model="ruleForm" label-width="100px" :rules="rules">
    <el-row>
      <el-col :span="12">
        <el-form-item label="入库编号:" prop="batchno">
          <el-input v-model="ruleForm.batchno" :disabled="true"></el-input>
7
        </el-form-item>
8 9 10 11
      </el-col>
      <el-col :span="12">
        <el-form-item label="登记机构:" prop="djjg">
          <el-select v-model="ruleForm.djjg" class="width100" placeholder="请选择" :disabled="!readOnly">
12
            <el-option v-for="item in DJJGLIST" :key="item.dname" :label="item.dname" :value="item.dname">
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
            </el-option>
          </el-select>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="入库人员:">
          <el-input v-model="ruleForm.operator" :disabled="true"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="入库时间:" prop="operationtime">
          <el-date-picker v-model="ruleForm.operationtime" class="width100" type="datetime" :disabled="!readOnly"
            value-format="yyyy-MM-dd HH:mm:ss">
          </el-date-picker>
        </el-form-item>
      </el-col>
    </el-row>
32 33 34 35 36 37 38 39 40
    <el-table :data="ruleForm.tableForm" border style="width: 100%"
      :header-cell-style="{ 'text-align': 'center', background: 'rgb(236, 245, 255)' }"
      :cell-style="{ 'text-align': 'center' }">
      <el-table-column prop="name" label="纸质证书类型" width="200"></el-table-column>
      <el-table-column prop="ksysxlh" label="开始印刷序列号" width="200">
        <template slot-scope="scope">
          <el-form-item
            :prop="'tableForm.' + scope.$index + '.ksysxlh'"
            :rules="rules.ksysxlh">
41 42
            <el-input v-model="scope.row.ksysxlh" @blur="ysxlhDeal(scope.row)" maxlength="11"
              oninput="value=value.replace(/[^\d.]/g,'')" :disabled="!readOnly"></el-input>
43 44 45 46 47 48 49 50
          </el-form-item>
        </template>
      </el-table-column>
      <el-table-column prop="jsysxlh" label="结束印刷序列号" width="200">
        <template slot-scope="scope">
          <el-form-item
            :prop="'tableForm.' + scope.$index + '.jsysxlh'"
            :rules="rules.jsysxlh">
51 52
            <el-input v-model="scope.row.jsysxlh" @blur="ysxlhDeal(scope.row)" maxlength="11"
              oninput="value=value.replace(/[^\d.]/g,'')" :disabled="!readOnly"></el-input>
53 54 55 56 57 58 59 60 61 62 63
          </el-form-item>
        </template>
      </el-table-column>
      <el-table-column prop="bs" label="本数">
        <template slot-scope="scope">
          <span v-if="scope.row.bs == 0" class="font-red">系统计算</span>
          <span v-else-if="scope.row.bs < 0" class="font-red">印刷序列号有误</span>
          <span v-else>{{ scope.row.bs }}</span>
        </template>
      </el-table-column>
    </el-table>
64 65 66
    <el-form-item label="备注" class="middle-margin-bottom">
      <el-input type="textarea" v-model="ruleForm.bz" :rows="4" :disabled="!readOnly"></el-input>
    </el-form-item>
67
    <el-form-item v-if="readOnly" style="text-align:center">
68 69 70 71
      <el-button type="primary" @click="submitForm">保存</el-button>
      <el-button @click="closeDialog">取消</el-button>
    </el-form-item>
  </el-form>
蔡俊立 committed
72 73 74
</template>

<script>
75 76 77 78 79 80 81 82
  import store from '@/store/index.js'
  import { zsrk, getZsglInfo } from "@/api/zsgl.js"
  import { getSysSerialSingle } from "@/api/sysSerial.js"
  export default {
    props: {
      formData: {
        type: Object,
        default: () => { },
任超 committed
83
      },
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
    },
    data () {
      return {
        DJJGLIST: store.getters.dictData['ywly'],
        readOnly: false,
        //表单提交数据
        ruleForm: {
          batchno: '',
          djjg: '',
          operator: '超级管理员',
          operationtime: '',
          bz: '',
          zsstarno: '',
          zsendno: '',
          zsnum: '',
          zmstarno: '',
          zmendno: '',
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
          zmnum: '',
          //表格数据
          tableForm: [
            {
              name: '不动产权证书',
              ksysxlh: '',
              jsysxlh: '',
              bs: 0,
              zslx: 1
            },
            {
              name: '不动产登记证明',
              ksysxlh: '',
              jsysxlh: '',
              bs: 0,
              zslx: 2
            }
          ]
蔡俊立 committed
119
        },
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
        //证书入库业务号参数
        ywhQueryForm: {
          serialtype: 'zsrkbh',
          serialname: '证书入库编号',
          serialcode: 'zsrk',
          digit: '5'
        },
        rules: {
          batchNo: [
            { required: true, message: '入库编号不能为空', trigger: 'blur' }
          ],
          djjg: [
            { required: true, message: '请选择登记机构', trigger: 'change' }
          ],
          rksj: [
            { required: true, message: '请选择入库时间', trigger: 'change' }
          ],
137 138 139 140 141 142
          ksysxlh: [
            { required: true, message: '开始印刷序列号不能为空', trigger: 'blur' }
          ],
          jsysxlh: [
            { required: true, message: '结束印刷序列号不能为空', trigger: 'blur' }
          ]
143 144
        },
      }
蔡俊立 committed
145
    },
146 147
    mounted () {
      if (this.formData.bsmBatch) {
148 149
        this.ruleForm.tableForm[0].bs = null;
        this.ruleForm.tableForm[1].bs = null;
150 151 152 153
        this.getDetailInfo(this.formData.bsmBatch);
      } else {
        this.ywhSerial();
      }
蔡俊立 committed
154
    },
155 156 157 158 159 160
    methods: {
      /**
       * @description: 表单提交
       * @author: renchao
       */
      submitForm () {
161 162 163 164 165 166 167 168
        let that = this
        this.$refs['ruleForm'].validate((valid) => {
          if (valid) {
            let arr = this.ruleForm.tableForm.filter(item => item.bs > 0)
            if (arr.length < 2) {
              that.$message.error('本书必须大于0,请检查印刷序列号');
              return
            }
169
            store.dispatch("user/refreshPage", false);
170 171 172 173 174 175
            zsrk(this.ruleForm).then(res => {
              if (res.code == 200) {
                that.$message.success('保存成功')
                that.$popupCacel()
                that.$refs['ruleForm'].resetFields()
                that.resetTableFields()
176
                store.dispatch("user/refreshPage", true);
177 178 179 180
              } else {
                that.$message.error(res.message);
              }
            })
181
          } else {
182
            return false;
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
          }
        })
      },
      /**
       * @description: 序列号获取
       * @author: renchao
       */
      ywhSerial () {
        getSysSerialSingle(this.ywhQueryForm).then(res => {
          if (res.code == 200) {
            this.ruleForm.batchno = res.message;
            this.readOnly = true;
          }
        })
      },
      /**
       * @description: 获取详情信息
       * @param {*} bsmBatch
       * @author: renchao
       */
      getDetailInfo (bsmBatch) {
        getZsglInfo({ "bsmBatch": bsmBatch }).then(res => {
          if (res.code == 200) {
            this.ruleForm = res.result;
            this.$refs.ruleForm.resetFields()
            this.readOnly = false;
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
            this.ruleForm.tableForm = [
              {
                ksysxlh: '',
                jsysxlh: '',
                bs: 0
              },
              {
                ksysxlh: '',
                jsysxlh: '',
                bs: 0
              }
            ]

            let zss = { ksysxlh: res.result.zsstarno, jsysxlh: res.result.zsendno, bs: res.result.zsnum, name: '不动产权证书', zslx: 1 };
            this.$set(this.ruleForm.tableForm, 0, zss)
            let zms = { ksysxlh: res.result.zmstarno, jsysxlh: res.result.zmendno, bs: res.result.zmnum, name: '不动产登记证明', zslx: 2 };
            this.$set(this.ruleForm.tableForm, 1, zms)
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
          }
        })
      },
      /**
       * @description: 印刷序列号处理
       * @param {*} item
       * @author: renchao
       */
      ysxlhDeal (item) {
        if (item.ksysxlh && item.jsysxlh) {
          if (item.ksysxlh.length == item.jsysxlh.length) {
            if (item.ksysxlh.length != 11) {
              item.bs = -1;
              return;
            }
            if (item.ksysxlh > item.jsysxlh) {
              item.bs = -1;
              return;
            }
            item.bs = item.jsysxlh - item.ksysxlh + 1;
            if (item.zslx == 1) {
              this.ruleForm.zsstarno = item.ksysxlh;
              this.ruleForm.zsendno = item.jsysxlh;
              this.ruleForm.zsnum = item.bs
            } else if (item.zslx == 2) {
              this.ruleForm.zmstarno = item.ksysxlh;
              this.ruleForm.zmendno = item.jsysxlh;
              this.ruleForm.zmnum = item.bs
            }
          } else {
蔡俊立 committed
256 257
            item.bs = -1;
          }
258 259
        } else {
          item.bs = 0;
任超 committed
260
          if (item.zslx == 1) {
261 262
            this.ruleForm.zsstarno = '';
            this.ruleForm.zsendno = '';
蔡俊立 committed
263
            this.ruleForm.zsnum = item.bs
任超 committed
264
          } else if (item.zslx == 2) {
265 266
            this.ruleForm.zmstarno = '';
            this.ruleForm.zmendno = '';
蔡俊立 committed
267 268
            this.ruleForm.zmnum = item.bs
          }
任超 committed
269
        }
270 271 272 273 274 275
      },
      /**
       * @description: resetTableFields
       * @author: renchao
       */
      resetTableFields () {
276
        this.ruleForm.tableForm = [
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
          {
            name: '不动产权证书',
            ksysxlh: '',
            jsysxlh: '',
            bs: 0,
            zslx: 1
          },
          {
            name: '不动产权登记证明',
            ksysxlh: '',
            jsysxlh: '',
            bs: 0,
            zslx: 2
          }
        ]
      },
      /**
       * @description: closeDialog
       * @author: renchao
       */
      closeDialog () {
        this.$popupCacel()
        this.$refs['ruleForm'].resetFields();
        this.resetTableFields();
蔡俊立 committed
301
      }
任超 committed
302
    }
蔡俊立 committed
303 304 305
  }
</script>
<style scoped lang="scss">
306 307
  @import "~@/styles/mixin.scss";
  @import "~@/styles/dialogBoxheader.scss";
308 309 310
  /deep/.cell .el-form-item {
    margin-bottom: 0;
  }
311 312 313
  .font-red {
    color: red;
  }
任超 committed
314

315 316 317
  .middle-margin-bottom {
    margin-top: 20px;
  }
蔡俊立 committed
318
</style>