Blame view

src/views/zsgl/zsrk/components/addDialog.vue 6.87 KB
蔡俊立 committed
1
<template>
任超 committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
  <dialogBox title="证书入库" @submitForm="submitForm" saveButton="保存" :isFullscreen="false" width="50%"
    @closeDialog="closeDialog" v-model="myValue">
    <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>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="登记机构:" prop="djjg">
            <el-select v-model="ruleForm.djjg" class="width100" placeholder="请选择">
              <el-option v-for="item in dictData['ywly']" :key="item.dname" :label="item.dname" :value="item.dname">
              </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.rkry" :disabled="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="入库时间:" prop="rksj">
            <el-date-picker v-model="ruleForm.rksj" class="width100" type="datetime">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <div>
        <el-table :data="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-input v-model="scope.row.ksysxlh" @blur="ysxlhDeal(scope.row)" maxlength="11"
                oninput="value=value.replace(/[^\d.]/g,'')"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="jsysxlh" label="结束印刷序列号" width="200">
            <template slot-scope="scope">
              <el-input v-model="scope.row.jsysxlh" @blur="ysxlhDeal(scope.row)" maxlength="11"
                oninput="value=value.replace(/[^\d.]/g,'')"></el-input>
            </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>
      </div>
      <el-form-item label="备注" class="middle-margin-bottom">
        <el-input type="textarea" v-model="ruleForm.bz" :rows="4"></el-input>
      </el-form-item>
    </el-form>
蔡俊立 committed
63 64 65 66 67
  </dialogBox>
</template>

<script>
import { mapGetters } from 'vuex'
任超 committed
68
import { getSysSerialSingle, zsrk } from "@/api/zsgl.js"
蔡俊立 committed
69 70 71 72 73 74 75 76 77
export default {
  computed: {
    ...mapGetters(['dictData']),
  },
  props: {
    value: { type: Boolean, default: false },
  },
  data () {
    return {
任超 committed
78
      myValue: this.value,
蔡俊立 committed
79
      //表单提交数据
蔡俊立 committed
80
      ruleForm: {
任超 committed
81 82 83 84 85 86 87 88 89 90 91 92
        batchno: '',
        djjg: '',
        rkry: '超级管理员',
        rksj: '',
        bz: '',
        zsstarno: '',
        zsendno: '',
        zsnum: '',
        zmstarno: '',
        zmendno: '',
        zmnum: ''
      },
蔡俊立 committed
93
      //表格数据
蔡俊立 committed
94 95 96 97 98
      tableForm: [
        {
          name: '不动产权证书',
          ksysxlh: '',
          jsysxlh: '',
蔡俊立 committed
99
          bs: 0,
任超 committed
100
          zslx: 1
蔡俊立 committed
101 102 103 104 105
        },
        {
          name: '不动产权登记证明',
          ksysxlh: '',
          jsysxlh: '',
蔡俊立 committed
106
          bs: 0,
任超 committed
107
          zslx: 2
蔡俊立 committed
108
        }
任超 committed
109
      ],
蔡俊立 committed
110
      //证书入库业务号参数
蔡俊立 committed
111 112 113 114 115 116 117
      ywhQueryForm: {
        serialtype: 'zsrkbh',
        serialname: '证书入库编号',
        serialcode: 'zsrk',
        digit: '5'
      },
      rules: {
任超 committed
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
        batchNo: [
          { required: true, message: '入库编号不能为空', trigger: 'blur' }
        ],
        djjg: [
          { required: true, message: '请选择登记机构', trigger: 'change' }
        ],
        rksj: [
          { required: true, message: '请选择入库时间', trigger: 'change' }
        ],
      },
    }
  },
  watch: {
    value (val) {
      this.myValue = val
蔡俊立 committed
133 134 135 136 137
    }
  },
  methods: {
    //表单提交
    submitForm () {
任超 committed
138 139 140 141
      this.tableForm.forEach((item, index) => {
        if (item.bs < 0) {
          return;
        }
蔡俊立 committed
142 143
      })
      zsrk(this.ruleForm).then(res => {
任超 committed
144
        if (res.code == 200) {
蔡俊立 committed
145
          this.$message.success('保存成功')
蔡俊立 committed
146
          this.$emit("input", false);
任超 committed
147
          this.$refs['ruleForm'].resetFields();
蔡俊立 committed
148
          this.resetTableFields();
蔡俊立 committed
149
          this.$parent.fetchData();
任超 committed
150
        } else {
蔡俊立 committed
151 152 153 154 155
          this.$message.error(res.message);
        }
      })
    },
    //序列号获取
任超 committed
156
    ywhSerial () {
蔡俊立 committed
157
      getSysSerialSingle(this.ywhQueryForm).then(res => {
任超 committed
158 159
        if (res.code == 200) {
          this.ruleForm.batchno = res.message;
蔡俊立 committed
160 161
        }
      })
蔡俊立 committed
162 163
    },
    //印刷序列号处理
任超 committed
164 165 166 167
    ysxlhDeal (item) {
      if (item.ksysxlh && item.jsysxlh) {
        if (item.ksysxlh.length == item.jsysxlh.length) {
          if (item.ksysxlh.length != 11) {
蔡俊立 committed
168 169 170
            item.bs = -1;
            return;
          }
任超 committed
171
          if (item.ksysxlh > item.jsysxlh) {
蔡俊立 committed
172 173 174 175
            item.bs = -1;
            return;
          }
          item.bs = item.jsysxlh - item.ksysxlh + 1;
任超 committed
176
          if (item.zslx == 1) {
蔡俊立 committed
177 178 179
            this.ruleForm.zsstarno = item.ksysxlh;
            this.ruleForm.zsendno = item.jsysxlh;
            this.ruleForm.zsnum = item.bs
任超 committed
180
          } else if (item.zslx == 2) {
蔡俊立 committed
181 182 183 184
            this.ruleForm.zmstarno = item.ksysxlh;
            this.ruleForm.zmendno = item.jsysxlh;
            this.ruleForm.zmnum = item.bs
          }
任超 committed
185
        } else {
蔡俊立 committed
186
          item.bs = -1;
蔡俊立 committed
187
        }
任超 committed
188
      } else {
蔡俊立 committed
189
        item.bs = 0;
任超 committed
190 191 192 193 194 195 196 197 198
        if (item.zslx == 1) {
          this.ruleForm.zsstarno = '';
          this.ruleForm.zsendno = '';
          this.ruleForm.zsnum = item.bs
        } else if (item.zslx == 2) {
          this.ruleForm.zmstarno = '';
          this.ruleForm.zmendno = '';
          this.ruleForm.zmnum = item.bs
        }
蔡俊立 committed
199 200
      }
    },
任超 committed
201
    resetTableFields () {
蔡俊立 committed
202 203 204 205 206 207
      this.tableForm = [
        {
          name: '不动产权证书',
          ksysxlh: '',
          jsysxlh: '',
          bs: 0,
任超 committed
208
          zslx: 1
蔡俊立 committed
209 210 211 212 213 214
        },
        {
          name: '不动产权登记证明',
          ksysxlh: '',
          jsysxlh: '',
          bs: 0,
任超 committed
215
          zslx: 2
蔡俊立 committed
216 217 218
        }
      ]
    },
蔡俊立 committed
219 220
    closeDialog () {
      this.$emit("input", false);
任超 committed
221 222
      this.$refs['ruleForm'].resetFields();
    }
蔡俊立 committed
223 224 225 226 227
  }
}
</script>
<style scoped lang="scss">
@import "~@/styles/mixin.scss";
任超 committed
228 229

.font-red {
蔡俊立 committed
230 231
  color: red
}
任超 committed
232 233 234

.middle-margin-bottom {
  margin-top: 20px
蔡俊立 committed
235
}
蔡俊立 committed
236
</style>