enclosure.vue 29.7 KB
Newer Older
786817560's avatar
786817560 committed
1 2 3 4
<!--
 * @Description: 附件信息
 * @Author: your name
 * @Date: 2019-09-20 09:35:11
786817560's avatar
786817560 committed
5
 * @LastEditTime: 2019-12-13 16:15:32
786817560's avatar
786817560 committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19
 * @LastEditors: Please set LastEditors
 -->
<template>
  <h-view id="enclosure" class="public-style">
    <h-header :proportion="[5,1,1]" class="bar-custom">
      <div slot="left" class="h-header-btn" @click="$routeGo()">
        <img src="@/assets/userBind/arrow.png">
        <span>附件信息</span>
      </div>
    </h-header>
    <h-content>
      <div v-for="(list, index) in cddItemList" :key="index" class="card2">
        <span>{{ list.description }}</span>
        <div class="img-content">
786817560's avatar
786817560 committed
20 21 22 23
          <!-- 房产 -->
          <div v-if="list.cdd_item==='HOUSE_CARD'">
            <div v-if="!houseImg" class="card-upload plus" @click="ocrShow(list.cdd_item, '')">
              <img src="@/assets/userBind/camera.png" class="upload-btn" >
786817560's avatar
786817560 committed
24
            </div>
786817560's avatar
786817560 committed
25
            <!-- 通过 -->
786817560's avatar
786817560 committed
26
            <div v-if="houseImg&&isApproved" class="card-upload">
786817560's avatar
786817560 committed
27 28 29 30 31
              <img :src="houseImg" @click="showBigPicture(houseImg)">
            </div>
            <!-- 未通过 -->
            <div v-if="houseImg&&!isApproved" class="card-upload">
              <img :src="houseImg" @click="ocrShow(list.cdd_item, '')">
786817560's avatar
786817560 committed
32 33
            </div>
          </div>
786817560's avatar
786817560 committed
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 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
          <div v-if="list.cdd_item==='HOUSE_CARD'">
            <list-item :item-height="44" class="card-Info">
              <item>
                <div slot="name">房屋所有权人</div>
                <input
                  slot="content"
                  v-model="hauseInfo.house_owner"
                  placeholder="识别房产证自动填充"
                >
              </item>
              <item>
                <div slot="name">共有情况</div>
                <input
                  slot="content"
                  v-model="hauseInfo.public_situation"
                  placeholder="识别房产证自动填充"
                >
              </item>
              <item>
                <div slot="name">房屋坐落</div>
                <input
                  slot="content"
                  v-model="hauseInfo.house_located"
                  placeholder="识别房产证自动填充"
                >
              </item>
              <item>
                <div slot="name">登记时间</div>
                <input
                  slot="content"
                  v-model="hauseInfo.regist_date"
                  placeholder="识别房产证自动填充"
                >
              </item>
              <item>
                <div slot="name">房屋性质</div>
                <input
                  slot="content"
                  v-model="hauseInfo.house_property"
                  placeholder="识别房产证自动填充"
                >
              </item>
              <item>
                <div slot="name">规划用途</div>
                <input
                  slot="content"
                  v-model="hauseInfo.plan_purpose"
                  placeholder="识别房产证自动填充"
                >
              </item>
              <item>
                <div slot="name">总层数</div>
                <input
                  slot="content"
                  v-model="hauseInfo.house_layers"
                  placeholder="识别房产证自动填充"
                >
              </item>
              <item>
                <div slot="name">建筑面积</div>
                <input
                  slot="content"
                  v-model="hauseInfo.built_area"
                  placeholder="识别房产证自动填充"
                >
              </item>
              <item>
                <div slot="name">套内建筑面积</div>
                <input
                  slot="content"
                  v-model="hauseInfo.built_in_area"
                  placeholder="识别房产证自动填充"
                >
              </item>
              <item>
                <div slot="name">其他</div>
786817560's avatar
786817560 committed
110
                <input slot="content" v-model="hauseInfo.others" placeholder="识别房产证自动填充" >
786817560's avatar
786817560 committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
              </item>
              <item>
                <div slot="name">地号</div>
                <input
                  slot="content"
                  v-model="hauseInfo.land_number"
                  placeholder="识别房产证自动填充"
                >
              </item>
              <item :proportion="[1,1]">
                <div slot="name">土地使用权取得方式</div>
                <input
                  slot="content"
                  v-model="hauseInfo.land_get_method"
                  placeholder="识别房产证自动填充"
                >
              </item>
              <item>
                <div slot="name">土地使用年限</div>
                <input
                  slot="content"
                  v-model="hauseInfo.land_use_limit"
                  placeholder="识别房产证自动填充"
                >
              </item>
            </list-item>
          </div>
786817560's avatar
786817560 committed
138 139 140 141 142 143 144 145 146 147 148 149
          <!-- 车辆 -->
          <div v-if="list.cdd_item==='CAR_CARD'">
            <div v-if="!carImg" class="card-upload plus" @click="ocrShow(list.cdd_item, '')">
              <img src="@/assets/userBind/camera.png" class="upload-btn" >
            </div>
            <!-- 通过 -->
            <div v-if="carImg&&isApproved" class="card-upload">
              <img :src="carImg" @click="showBigPicture(carImg)">
            </div>
            <!-- 未通过 -->
            <div v-if="carImg&&!isApproved" class="card-upload">
              <img :src="carImg" @click="ocrShow(list.cdd_item, '')">
786817560's avatar
786817560 committed
150
            </div>
786817560's avatar
786817560 committed
151
          </div>
786817560's avatar
786817560 committed
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 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 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
          <div v-if="list.cdd_item==='CAR_CARD'">
            <list-item :item-height="44" class="card-Info">
              <item>
                <div slot="name">车辆识别代号</div>
                <input
                  slot="content"
                  v-model="carInfo.vehicle_identify_num"
                  readonly
                  placeholder="识别行驶证自动填充"
                >
              </item>
              <item>
                <div slot="name">住址</div>
                <input slot="content" v-model="carInfo.address" readonly placeholder="识别行驶证自动填充" >
              </item>
              <item>
                <div slot="name">品牌型号</div>
                <input
                  slot="content"
                  v-model="carInfo.brand_model_number"
                  readonly
                  placeholder="识别行驶证自动填充"
                >
              </item>
              <item>
                <div slot="name">发证日期"</div>
                <input slot="content" v-model="carInfo.start_date" readonly placeholder="识别行驶证自动填充" >
              </item>
              <item>
                <div slot="name">车辆类型</div>
                <input
                  slot="content"
                  v-model="carInfo.vehicle_type"
                  readonly
                  placeholder="识别行驶证自动填充"
                >
              </item>
              <item>
                <div slot="name">所有人</div>
                <input slot="content" v-model="carInfo.owner" readonly placeholder="识别行驶证自动填充" >
              </item>
              <item>
                <div slot="name">使用性质</div>
                <input slot="content" v-model="carInfo.use_nature" readonly placeholder="识别行驶证自动填充" >
              </item>
              <item>
                <div slot="name">发动机号码</div>
                <input
                  slot="content"
                  v-model="carInfo.engine_number"
                  readonly
                  placeholder="识别行驶证自动填充"
                >
              </item>
              <item>
                <div slot="name">号牌号码</div>
                <input
                  slot="content"
                  v-model="carInfo.plate_number"
                  readonly
                  placeholder="识别行驶证自动填充"
                >
              </item>
              <item>
                <div slot="name">注册日期</div>
                <input
                  slot="content"
                  v-model="carInfo.regist_date"
                  readonly
                  placeholder="识别行驶证自动填充"
                >
              </item>
            </list-item>
          </div>
786817560's avatar
786817560 committed
226 227
          <!-- 其他 -->
          <div v-if="list.cdd_item==='ASSETS_CARD'">
786817560's avatar
786817560 committed
228 229
            <!--待上传图片列表-->
            <div
786817560's avatar
786817560 committed
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
              v-for="(item, index) in upload_list"
              v-if="item.check_id==list.check_id"
              :key="index"
              class="card-upload"
            >
              <img :src="item.picture" @click="showBigPicture(item.picture)" >
              <div class="close" @click="remove_pic(item.attachment_id,index)">
                <img src="@/assets/userBind/deleteIcon.png" >
              </div>
            </div>
            <!--从服务器上下载的图片-->
            <div v-for="(pic, index) in dowload_list[0]" :key="index">
              <div v-if="pic.check_id==list.check_id" :key="index" class="card-upload">
                <img :src="pic.url" @click="showBigPicture(pic.url)" >
                <div class="close" @click="delete_pic(pic.attachment_id)">
                  <img src="@/assets/userBind/deleteIcon.png" >
                </div>
786817560's avatar
786817560 committed
247 248
              </div>
            </div>
786817560's avatar
786817560 committed
249
            <div class="card-upload plus" @click="imgUploadShow(list.description,list.check_id)">
786817560's avatar
786817560 committed
250
              <img src="@/assets/userBind/camera.png" class="upload-btn" >
786817560's avatar
786817560 committed
251
            </div>
786817560's avatar
786817560 committed
252 253 254
          </div>
        </div>
      </div>
786817560's avatar
786817560 committed
255
      <!-- </div> -->
786817560's avatar
786817560 committed
256 257 258 259 260 261 262 263 264 265
    </h-content>
    <bottom-tab class="footer-button">
      <tab-button class="save" @click.native="verified">下一步</tab-button>
    </bottom-tab>
  </h-view>
</template>
<script>
export default {
  data () {
    return {
786817560's avatar
786817560 committed
266 267 268 269
      house_id: '', // 房产证checkid
      car_id: '', // 车辆证checkid
      carFlag: false, // 行驶证查看标识,为false则用查询出来的,为true则用拍照出来的
      houseFlag: false, // 房产证查看标识,为false则用查询出来的,为true则用拍照出来的
786817560's avatar
786817560 committed
270 271
      carImg: '',
      houseImg: '',
786817560's avatar
786817560 committed
272 273 274
      from: false,
      bp_id: '',
      flag: false,
786817560's avatar
786817560 committed
275
      isApproved: false,
786817560's avatar
786817560 committed
276 277
      isUploadCar: false,
      isUploadHouse: false,
786817560's avatar
786817560 committed
278 279
      carAttachmentId: '', // 车辆证id
      houseAttachmentId: '', // 房产证id
786817560's avatar
786817560 committed
280 281 282
      cddItemList: [], // 资料清单列表
      dowload_list: [], // 下载图片列表
      upload_list: [], // 上传图片列表
786817560's avatar
786817560 committed
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
      carInfo: {
        bp_id: this.$route.params.bp_id,
        vehicle_identify_num: '',
        address: '',
        brand_model_number: '',
        start_date: '',
        vehicle_type: '',
        owner: '',
        use_nature: '',
        engine_number: '',
        plate_number: '',
        regist_date: '',
        words_result_num: '',
        success: '',
      },
      hauseInfo: {
        bp_id: this.$route.params.bp_id,
        house_owner: '',
        public_situation: '',
        house_located: '',
        regist_date: '',
        house_property: '',
        plan_purpose: '',
        house_layers: '',
        built_area: '',
        built_in_area: '',
        others: '',
        land_number: '',
        land_get_method: '',
        land_use_limit: '',
      },
786817560's avatar
786817560 committed
314 315 316 317 318 319 320 321 322
    }
  },
  watch: {},
  beforeRouteEnter (to, from, next) {
    next(vm => {
      if (from.name === 'Invoice') {
        vm.upload_list = [] // 上传图片列表
        vm.dowload_list = []
        vm.cddItemList = []
786817560's avatar
786817560 committed
323
        vm.isApproved = window.localStorage.isApproved
786817560's avatar
786817560 committed
324 325
        vm.bp_id = vm.$route.params.bp_id
        vm.loadItemList()
786817560's avatar
786817560 committed
326 327
        vm.houseQuery()
        vm.carQuery()
786817560's avatar
786817560 committed
328 329 330 331 332
      }
    })
  },
  created () {},
  methods: {
786817560's avatar
786817560 committed
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
    // 房产证信息查询
    houseQuery () {
      let vm = this
      let url = process.env.basePath + 'bp_house_info_query'
      let param = {
        bp_id: vm.bp_id,
      }
      hlsPopup.showLoading('请稍候')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          Object.assign(vm.hauseInfo, res.info)
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    // 行驶证信息查询
    carQuery () {
      let vm = this
      let url = process.env.basePath + 'bp_vehicleLicense_query'
      let param = {
        bp_id: vm.bp_id,
      }
      hlsPopup.showLoading('请稍候')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          Object.assign(vm.carInfo, res.info)
        } else {
          hlsPopup.showLongCenter(res.message)
        }
786817560's avatar
786817560 committed
365
      })
786817560's avatar
786817560 committed
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
    },
    // 行驶证信息保存
    saveCarInfo () {
      let vm = this
      let url = process.env.basePath + 'bp_vehicleLicense_save'
      let param = {
        master: vm.carInfo,
      }
      hlsPopup.showLoading('请稍候')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.$router.push({
            name: 'BankInfo',
            params: {
              bp_id: vm.bp_id,
            },
          })
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    // 房产证信息保存
    saveHouseInfo () {
      let vm = this
      let url = process.env.basePath + 'bp_house_info_save'
      let param = {
        master: vm.hauseInfo,
      }
786817560's avatar
786817560 committed
396
      // hlsPopup.showLoading('请稍候')
786817560's avatar
786817560 committed
397
      vm.$post(url, param).then(function (res) {
786817560's avatar
786817560 committed
398
        // vm.hlsPopup.hideLoading()
786817560's avatar
786817560 committed
399 400 401 402 403 404 405 406
        if (res.result === 'S') {
          vm.saveCarInfo()
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    verified () {
786817560's avatar
786817560 committed
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
      let vm = this
      if (vm.isUploadHouse) {
        vm.houseFlag = true
        vm.delete_pic_to_ocr(vm.houseAttachmentId) // 房产证修改,重新上传
        let list = []
        let obj = {
          pkvalue: vm.house_id,
          source_type: 'PRJ_CDD_ITEM_CHECK',
          picture: '',
          check_id: vm.house_id,
          filePath: vm.houseImg,
          attachment_id: '',
          user_id: 1,
          fileName: '房产证',
        }
        list.push(obj)
        vm.save_picture(list)
        vm.isUploadHouse = false // 置为false,防止再次保存重复上传,只有重新识别才会重新上传
      }
      if (vm.isUploadCar) {
        vm.carFlag = true
        vm.delete_pic_to_ocr(vm.carAttachmentId) // 房产证修改,重新上传
        let list = []
        let obj = {
          pkvalue: vm.car_id,
          source_type: 'PRJ_CDD_ITEM_CHECK',
          picture: '',
          check_id: vm.car_id,
          filePath: vm.carImg,
          attachment_id: '',
          user_id: 1,
          fileName: '行驶证',
        }
        list.push(obj)
        vm.save_picture(list)
        vm.isUploadCar = false // 置为false,防止再次保存重复上传,只有重新识别才会重新上传
      }
786817560's avatar
786817560 committed
444
      vm.saveHouseInfo()
786817560's avatar
786817560 committed
445
    },
786817560's avatar
786817560 committed
446 447
    // 房产证/车辆证识别
    ocrShow (ocrType, type) {
786817560's avatar
786817560 committed
448
      let vm = this
786817560's avatar
786817560 committed
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466
      hlsPopup.showActionSheet({
        titleText: '请选择照片',
        buttonArray: ['拍照', '从相册取'],
        callback: index => {
          if (index === 0) {
            vm.openCamera(ocrType, type)
          } else {
            vm.takePicture(ocrType, type)
          }
        },
      })
    },
    openCamera (ocrType, type) {
      let vm = this
      let cameraoptions = {
        quality: 60,
        width: 1843,
        height: 1382,
786817560's avatar
786817560 committed
467
      }
786817560's avatar
786817560 committed
468 469 470
      let success = function (imgdata) {
        if (!imgdata) {
          hlsPopup.showLongCenter('请拍照')
786817560's avatar
786817560 committed
471
        } else {
786817560's avatar
786817560 committed
472 473 474
          if (ocrType === 'HOUSE_CARD') {
            vm.isUploadHouse = true
            vm.houseImg = imgdata
786817560's avatar
786817560 committed
475
            vm.houseCardIdentify(imgdata)
786817560's avatar
786817560 committed
476 477 478
          } else if (ocrType === 'CAR_CARD') {
            vm.isUploadCar = true
            vm.carImg = imgdata
786817560's avatar
786817560 committed
479
            vm.carCardIdentify(imgdata)
786817560's avatar
786817560 committed
480
          }
786817560's avatar
786817560 committed
481
        }
786817560's avatar
786817560 committed
482 483 484 485 486
      }
      let error = function () {
        hlsPopup.showLongCenter('请拍照')
      }
      hlsUtil.openCamera(cameraoptions, success, error)
786817560's avatar
786817560 committed
487
    },
786817560's avatar
786817560 committed
488 489 490 491 492 493 494 495 496 497 498 499 500 501
    takePicture (ocrType, type) {
      let vm = this
      var cameraoptions = {
        quality: 70,
        width: 1843,
        height: 1382,
        maxCount: 1,
      }
      let success = function (imgUrl) {
        if (imgUrl.length === 0) {
          hlsPopup.showLongCenter('请选择一张图片')
        } else {
          if (ocrType === 'HOUSE_CARD') {
            vm.houseImg = imgUrl[0]
786817560's avatar
786817560 committed
502
            vm.isUploadHouse = true
786817560's avatar
786817560 committed
503
            vm.houseCardIdentify(imgUrl[0])
786817560's avatar
786817560 committed
504 505
          } else if (ocrType === 'CAR_CARD') {
            vm.carImg = imgUrl[0]
786817560's avatar
786817560 committed
506
            vm.isUploadCar = true
786817560's avatar
786817560 committed
507
            vm.carCardIdentify(imgUrl[0])
786817560's avatar
786817560 committed
508 509 510 511 512 513 514 515
          }
        }
      }
      let error = function () {
        hlsPopup.showLongCenter(error)
      }
      vm.hlsUtil.takePicture(cameraoptions, success, error)
    },
786817560's avatar
786817560 committed
516
    // 房产证识别
786817560's avatar
786817560 committed
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538
    houseCardIdentify (fileUrl) {
      let vm = this
      hlsPopup.showLoading('正在识别')
      let url = process.env.ocrPath + '/baidu/ocr/house'
      hlsUtil.baiduOcr(fileUrl, url, function (res) {
        hlsPopup.hideLoading()
        let result = res.result.data
        vm.hauseInfo.house_owner = result.house_owner.word
        vm.hauseInfo.public_situation = result.public_situation.word
        vm.hauseInfo.house_located = result.house_located.word
        vm.hauseInfo.regist_date = result.regist_date.word
        vm.hauseInfo.house_property = result.house_property.word
        vm.hauseInfo.plan_purpose = result.plan_purpose.word
        vm.hauseInfo.house_layers = result.house_layers.word
        vm.hauseInfo.built_area = result.built_area.word
        vm.hauseInfo.built_in_area = result.built_in_area.word
        vm.hauseInfo.others = result.others.word
        vm.hauseInfo.land_number = result.land_number.word
        vm.hauseInfo.land_get_method = result.land_get_method.word
        vm.hauseInfo.land_use_limit = result.land_use_limit.word
      })
    },
786817560's avatar
786817560 committed
539
    // 行驶证识别
786817560's avatar
786817560 committed
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559
    carCardIdentify (fileUrl) {
      let vm = this
      hlsPopup.showLoading('正在识别')
      let url = process.env.ocrPath + '/baidu/ocr/vehicleLicense'
      hlsUtil.baiduOcr(fileUrl, url, function (res) {
        hlsPopup.hideLoading()
        let result = res.result.words_result
        vm.carInfo.vehicle_identify_num = result.车辆识别代号.words
        vm.carInfo.address = result.住址.words
        vm.carInfo.brand_model_number = result.品牌型号.words
        vm.carInfo.start_date = result.发证日期.words
        vm.carInfo.vehicle_type = result.车辆类型.words
        vm.carInfo.owner = result.所有人.words
        vm.carInfo.use_nature = result.使用性质.words
        vm.carInfo.engine_number = result.发动机号码.words
        vm.carInfo.plate_number = result.号牌号码.words
        vm.carInfo.regist_date = result.注册日期.words
        vm.carInfo.words_result_num = res.result.words_result_num
        vm.carInfo.success = res.success
      })
786817560's avatar
786817560 committed
560
    },
786817560's avatar
786817560 committed
561 562 563 564 565 566 567 568 569 570 571 572 573
    loadItemList () {
      let vm = this
      let url = process.env.basePath + 'prj_cdd_check_list'
      let param = {
        master: {
          'document_id': vm.bp_id,
          'document_table': 'HLS_BP_MASTER',
          'tab_group': window.localStorage.authFlag ? 'HLS_ORG_NAUTH' : 'HLS_ORG_AUTH',
        },
      }
      vm.hlsHttp.post(url, param).then(function (res) {
        if (res.result === 'S') {
          vm.cddItemList = []
786817560's avatar
786817560 committed
574 575 576 577 578 579
          var listTemp = [...res.lists]
          listTemp.forEach(item => {
            switch (item.cdd_item) {
              case 'HOUSE_CARD': // 房产证
                vm.house_id = item.check_id
                break
786817560's avatar
786817560 committed
580
              case 'CAR_CARD': // 行驶证
786817560's avatar
786817560 committed
581 582 583 584 585 586
                vm.car_id = item.check_id
                break
              default:
                break
            }
          })
786817560's avatar
786817560 committed
587
          vm.cddItemList = res.lists.filter(item => { return item.cdd_item === 'HOUSE_CARD' || item.cdd_item === 'CAR_CARD' || item.cdd_item === 'ASSETS_CARD' })
786817560's avatar
786817560 committed
588
          // 查询图片
786817560's avatar
786817560 committed
589 590
          vm.cddItemList.forEach((item, index) => {
            vm.load_picture(item.check_id, index, item.cdd_item)
786817560's avatar
786817560 committed
591
          })
786817560's avatar
786817560 committed
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608
        }
      })
    },

    load_picture (check_id, index, cdd_item) {
      let vm = this
      let url = process.env.basePath + 'attachment_list_query' + '&index' + index // 附件查询
      let param = {
        check_id: check_id,
      }
      hlsPopup.showLoading('请稍候')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          res.lists.forEach(item => {
            item['url'] = process.env.filePath + 'attachment_id=' + item.attachment_id + '&access_token=' + window.localStorage.access_token
          })
786817560's avatar
786817560 committed
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624
          switch (cdd_item) {
            case 'HOUSE_CARD': // 房产证
              if (!vm.houseFlag) {
                vm.houseImg = res.lists[0].url
              }
              vm.houseAttachmentId = res.lists[0].attachment_id
              break
            case 'CAR_CARD': // 行驶证
              if (!vm.carFlag) {
                vm.carImg = res.lists[0].url
              }
              vm.carAttachmentId = res.lists[0].attachment_id
              break
            default:
              vm.dowload_list.push(res.lists)
          }
786817560's avatar
786817560 committed
625 626
        } else {
          hlsPopup.showLongCenter(res.message)
786817560's avatar
786817560 committed
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769
        }
      })
    },
    // 图片上传入口
    imgUploadShow (description, check_id) {
      let vm = this
      hlsPopup.showActionSheet({
        titleText: '请选择照片',
        buttonArray: ['拍照', '从相册取'],
        callback: index => {
          if (index === 0) {
            vm.imgUploadOpenCamera(description, check_id)
          } else {
            vm.imgUploadTakePicture(description, check_id)
          }
        },
      })
    },
    imgUploadOpenCamera (description, check_id) {
      let vm = this
      let obj = {
        'pkvalue': check_id,
        'source_type': 'PRJ_CDD_ITEM_CHECK',
        'picture': '',
        'check_id': check_id,
        'filePath': '',
        'attachment_id': '',
        'user_id': 1,
        'fileName': description + '_' + new Date().getTime(),
      }
      let cameraoptions = {
        quality: 100,
      }
      let success = function (imgdata) {
        obj.picture = imgdata
        obj.filePath = imgdata
        let list = []
        list.push(obj)
        // 拍完一张立马执行保存图片逻辑
        vm.save_picture(list)
      }
      let error = function () {
        hlsPopup.showLongCenter('请拍照')
      }
      hlsUtil.openCamera(cameraoptions, success, error)
    },
    imgUploadTakePicture (description, check_id) {
      let vm = this
      let cameraoptions = {
        quality: 100,
      }
      let success = function (imgUrl) {
        var list = []
        for (let i = 0; i < imgUrl.length; i++) {
          let obj = {
            'pkvalue': check_id,
            'source_type': 'PRJ_CDD_ITEM_CHECK',
            'picture': '',
            'check_id': check_id,
            'filePath': '',
            'attachment_id': '',
            'user_id': 1,
            'fileName': description + '_' + new Date().getTime(),
          }
          obj.picture = imgUrl[i]
          obj.filePath = imgUrl[i]
          list.push(obj)
        }
        vm.save_picture(list)
      }
      let error = function () {
      }
      vm.hlsUtil.takePicture(cameraoptions, success, error)
    },
    // 查看大图
    showBigPicture (pic) {
      let vm = this
      vm.hlsPopup.showBigPicture({
        imgUrl: pic,
        width: '100%',
      })
    },
    // 移除图片
    remove_pic (attachment_id, index) {
      let vm = this
      var delete_list = []
      let obj = {'attachment_id': attachment_id}
      delete_list.push(obj)
      let url = process.env.basePath + 'app_delete_attment' // 附件删除
      let param = {
        'picturelist': delete_list,
      }
      hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        hlsPopup.hideLoading()
        if (res.result === 'S') {
          hlsPopup.showLongCenter('删除成功!')
          vm.remove_upload_list(attachment_id, index)
        } else if (res.result === 'E') {
          hlsPopup.showShortCenter(res.message)
        }
      })
    },
    remove_upload_list (attachment_id, index) {
      let vm = this
      vm.upload_list.remove(index)
      vm.upload_list.sort()
    },
    // 删除图片
    delete_pic (attachment_id) {
      let vm = this
      var delete_list = []
      let obj = {'attachment_id': attachment_id}
      delete_list.push(obj)
      let url = process.env.basePath + 'app_delete_attment' // 附件删除
      let param = {
        'picturelist': delete_list,
      }
      hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        hlsPopup.hideLoading()
        if (res.result === 'S') {
          hlsPopup.showLongCenter('删除成功!')
          vm.remove_dowload_list(attachment_id)
        } else if (res.result === 'E') {
          hlsPopup.showShortCenter(res.message)
        }
      })
    },
    remove_dowload_list (attachment_id) {
      let vm = this
      for (let i = 0; i < vm.dowload_list.length; i++) {
        let list = vm.dowload_list[i]
        for (let j = 0; j < list.length; j++) {
          let li = list[j]
          if (parseFloat(li.attachment_id) === parseFloat(attachment_id)) {
            list.remove(j)
            break
          }
        }
      }
      vm.dowload_list.sort()
    },
786817560's avatar
786817560 committed
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807
    // 图片保存
    save_picture (list) {
      let vm = this
      if (list.length) {
        // hlsPopup.showLoading('图片上传请稍候')
        var alreadyUploadNum = 0
        var attLength = 0
        var recordUploadInterval = setInterval(function () {
          if (alreadyUploadNum === attLength) {
            clearInterval(recordUploadInterval)
            /*  hlsPopup.hideLoading()
                hlsPopup.showLongCenter('图片上传成功') */
          }
        }, 500)
        for (var i = 0; i < list.length; i++) {
          let uploadSuccess = function (res) {
            if (res.result === 'S') {
              alreadyUploadNum++
              for (var j = 0; j < list.length; j++) {
                if (list[j].filePath === res.response.filePath) {
                  list[j].attachment_id = res.response.attachment_id
                  vm.upload_list.push(list[j])
                  break
                }
              }
            } else {
              hlsPopup.hideLoading()
            }
          }
          if (!list[i].attachment_id) {
            attLength++
            hlsUtil.fileUploadSvc(list[i], uploadSuccess)
          }
        }
      } else {
        hlsPopup.hideLoading()
      }
    },
786817560's avatar
786817560 committed
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824
    // 删除重新识别之前的图
    delete_pic_to_ocr (attachment_id) {
      let vm = this
      var delete_list = []
      let obj = { attachment_id: attachment_id }
      delete_list.push(obj)
      let url = process.env.basePath + 'app_delete_attment' // 附件删除
      let param = {
        picturelist: delete_list,
      }
      vm.hlsHttp.post(url, param).then(function (res) {
        hlsPopup.hideLoading()
        if (res.result === 'S') {
        } else if (res.result === 'E') {
        }
      })
    },
786817560's avatar
786817560 committed
825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950
  },
}
</script>
<style lang='less'>
#enclosure {

    .footer-button {
      padding-top: 15px;
      padding-bottom: 15px;
    }
    .save {
      width: 100%;
      height: 45px;
      color: #fff;
      border-radius: 4px;
      background-color: @headerColor;
    }
    .card2 {
        padding-bottom: 8px;
        height: auto;
        background-color: #fff;
        margin-bottom: 10px;

        display: flex;
        flex-direction: column;

        span {
          color: #656464;
          font-size: 13px;
          line-height: 18px;
          padding-top: 8px;
          display: block;
          margin-left: 16px;
        }

        .img-content {
          /* display: flex;
           flex-flow: row wrap;
           justify-content: flex-start;
           align-items: center;*/
        }

        .plus {
          display: flex;
          justify-content: center;
          align-items: center;
        }

        .card-upload {
          position: relative;
          width: 80px;
          height: 80px;
          border: 1px dashed #dcdcdd;
          /* display: flex;
           justify-content: center;
           align-items: center;*/
          margin-top: 12px;
          margin-left: 16px;
          float: left;

          .close {
            /* position: relative;
             color: #F96F68;
             margin-top: -100%;
             margin-left: -10%;*/
            position: absolute;
            color: #F96F68;
            top: -6px;
            right: -6px;

            img {
              width: 14px;
              height: 14px;
            }
          }

          img {
            /*width: 88px;
            height: 88px;*/
            width: 100%;
            height: 100%;
          }

          .upload-btn {
            width: 24px;
            height: 24px;
          }
        }
    }
    .upload-id-card {
        height: 122px;
        background-color: #fff;

        span {
          display: block;
          color: #656464;
          margin-left: 16px;
          padding-top: 16px;
          font-size: 13px;
        }

        .upload-box1 {
          width: 80px;
          height: 80px;
          border: 1px dashed #dcdcdd;
          text-align: center;
          margin-top: 8px;
          margin-left: 16px;

          .licenseBox {
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
          }

          img {
            margin-top: 30px;
            width: 25px;
            height: 25px;
          }
        }
      }
}
</style>