Blame view

src/views/zsgl/zsrk/components/addDialog.vue 7.82 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 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 63 64 65
      </el-col>
      <el-col :span="12">
        <el-form-item label="登记机构:" prop="djjg">
          <el-select v-model="ruleForm.djjg" class="width100" placeholder="请选择" :disabled="!readOnly">
            <el-option v-for="item in  DJJGLIST" :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.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>
    <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,'')" :disabled="!readOnly"></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,'')" :disabled="!readOnly"></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" :disabled="!readOnly"></el-input>
    </el-form-item>
    <el-form-item v-if="readOnly">
      <el-button type="primary" @click="submitForm">保存</el-button>
      <el-button @click="closeDialog">取消</el-button>
    </el-form-item>
  </el-form>
蔡俊立 committed
66 67 68
</template>

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

任超 committed
255
.font-red {
蔡俊立 committed
256 257
  color: red
}
任超 committed
258 259 260

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