MrShi
2024-02-22 e622bd5e3b2638b9ab9a712ed1160a66018d6fd7
company/src/components/business/OperaCompanyDescWindow.vue
@@ -180,156 +180,163 @@
</template>
<script>
    import BaseOpera from '@/components/base/BaseOpera'
    import GlobalWindow from '@/components/common/GlobalWindow'
    import OperaCompanyWindow from '@/components/business/OperaCompanyWindow'
    import modification from '@/components/business/modification'
    import { getById, updatePhone } from '@/api/business/company'
    import { listForCompany } from '@/api/business/solutions'
    import { sendSms } from '@/api/business/smsEmail'
    export default {
        name: 'OperaCompanyDescWindow',
        extends: BaseOpera,
        components: { GlobalWindow, OperaCompanyWindow, modification },
        data () {
            return {
                ruleForm: {
                    phone: '',
                    code: ''
                },
                num: 0,
                timer: null,
                // 表单数据
                form: {},
                phone: '',
                code: '',
                visiblePhone: false,
                options: [],
                tableData: []
            }
        },
        created () {
            this.config({
                api: '/business/company',
                'field.id': 'id'
            })
        },
        methods: {
            close() {
                this.visiblePhone = false
                this.phone = ''
                this.code = ''
                clearInterval(this.timer)
                this.num = 0
            },
            updatePhoneEvent() {
                if (!this.phone) {
                    this.$message.warning('请输入手机号')
                    return
                }
                if (!this.code) {
                    this.$message.warning('请输入验证码')
                    return
                }
                updatePhone({
                    id: this.form.id,
                    captche: this.code,
                    phone: this.phone
                }).then(res => {
                    this.form.phone = JSON.parse(JSON.stringify(this.phone))
                    this.$message.success('操作成功')
                    this.visiblePhone = false
                    this.phone = ''
                    this.code = ''
                    clearInterval(this.timer)
                    this.num = 0
                })
            },
            send() {
                if (!this.phone) {
                    this.$message.warning('请输入手机号')
                    return
                }
                sendSms({ phone: this.phone })
                    .then(res => {
                        this.num = 60
                        this.setTime()
                    })
            },
            setTime() {
                this.timer = setInterval(() => {
                    this.num -= 1
                    if (this.num === 0) {
                        clearInterval(this.timer)
                        this.num = 0
                    }
                }, 1000)
            },
            open (title, target) {
                const that = this;
                this.title = title
                this.phone = ''
                this.code = ''
                clearInterval(this.timer)
                this.num = 0
                getById(target.id)
                    .then(res => {
                        this.form = res
                        this.form.type = 1
                        this.form.file = {
                            imgurl: '',
                            imgurlfull: ''
                        }
                        this.form.file1 = {
                            imgurl: '',
                            imgurlfull: ''
                        }
                        this.form.file2 = {
                            imgurl: '',
                            imgurlfull: ''
                        }
                        this.form.file3 = {
                            imgurl: '',
                            imgurlfull: ''
                        }
                        this.form.file.imgurl = res.businessImg.fileurl
                        this.form.file.imgurlfull = res.businessImg.fileurlFull
                        this.form.file1.imgurl = res.idcardImgList[0].fileurl
                        this.form.file1.imgurlfull = res.idcardImgList[0].fileurlFull
                        this.form.file2.imgurl = res.idcardImgList[1].fileurl
                        this.form.file2.imgurlfull = res.idcardImgList[1].fileurlFull
                        this.form.file3.imgurl = res.signImg.fileurl
                        this.form.file3.imgurlfull = res.signImg.fileurlFull
                        listForCompany({ companyId: target.id })
                            .then(resa => {
                                that.form.solutionList = resa.map(item => {
                                    return {
                                        solutionBaseId: item.solutionBaseId,
                                        canAdd: item.canAdd,
                                        canReduce: item.canReduce
                                    }
                                })
                                that.form.solutionListName = resa.map(item => {
                                    return {
                                        solutionName: item.solutionName,
                                        canAdd: item.canAdd,
                                        canReduce: item.canReduce
                                    }
                                })
                                console.log(that.form)
                                that.visible = true
                            })
                    })
            },
            callback() {
                this.$emit('success')
                this.visible = false
            }
        }
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
import OperaCompanyWindow from '@/components/business/OperaCompanyWindow'
import modification from '@/components/business/modification'
import { getById, updatePhone } from '@/api/business/company'
import { listForCompany } from '@/api/business/solutions'
import { sendSms } from '@/api/business/smsEmail'
export default {
  name: 'OperaCompanyDescWindow',
  extends: BaseOpera,
  components: { GlobalWindow, OperaCompanyWindow, modification },
  data () {
    return {
      ruleForm: {
        phone: '',
        code: ''
      },
      dataId: null,
      num: 0,
      timer: null,
      // 表单数据
      form: {},
      phone: '',
      code: '',
      visiblePhone: false,
      options: [],
      tableData: []
    }
  },
  created () {
    this.config({
      api: '/business/company',
      'field.id': 'id'
    })
  },
  methods: {
    close () {
      this.visiblePhone = false
      this.phone = ''
      this.code = ''
      clearInterval(this.timer)
      this.num = 0
    },
    updatePhoneEvent () {
      if (!this.phone) {
        this.$message.warning('请输入手机号')
        return
      }
      if (!this.code) {
        this.$message.warning('请输入验证码')
        return
      }
      updatePhone({
        id: this.form.id,
        captche: this.code,
        phone: this.phone
      }).then(res => {
        this.form.phone = JSON.parse(JSON.stringify(this.phone))
        this.$message.success('操作成功')
        this.visiblePhone = false
        this.phone = ''
        this.code = ''
        clearInterval(this.timer)
        this.num = 0
      })
    },
    send () {
      if (!this.phone) {
        this.$message.warning('请输入手机号')
        return
      }
      sendSms({ phone: this.phone })
        .then(res => {
          this.num = 60
          this.setTime()
        })
    },
    setTime () {
      this.timer = setInterval(() => {
        this.num -= 1
        if (this.num === 0) {
          clearInterval(this.timer)
          this.num = 0
        }
      }, 1000)
    },
    open (title, target) {
      const that = this
      this.title = title
      this.dataId = target.id
      this.phone = ''
      this.code = ''
      clearInterval(this.timer)
      this.num = 0
      this.getDetail()
    },
    getDetail () {
      var that =this
      getById(this.dataId)
        .then(res => {
          this.form = res
          this.form.type = 1
          this.form.file = {
            imgurl: '',
            imgurlfull: ''
          }
          this.form.file1 = {
            imgurl: '',
            imgurlfull: ''
          }
          this.form.file2 = {
            imgurl: '',
            imgurlfull: ''
          }
          this.form.file3 = {
            imgurl: '',
            imgurlfull: ''
          }
          this.form.file.imgurl = res.businessImg.fileurl
          this.form.file.imgurlfull = res.businessImg.fileurlFull
          this.form.file1.imgurl = res.idcardImgList[0].fileurl
          this.form.file1.imgurlfull = res.idcardImgList[0].fileurlFull
          this.form.file2.imgurl = res.idcardImgList[1].fileurl
          this.form.file2.imgurlfull = res.idcardImgList[1].fileurlFull
          this.form.file3.imgurl = res.signImg.fileurl
          this.form.file3.imgurlfull = res.signImg.fileurlFull
          listForCompany({ companyId: this.dataId })
            .then(resa => {
              that.form.solutionList = resa.map(item => {
                return {
                  solutionBaseId: item.solutionBaseId,
                  canAdd: item.canAdd,
                  canReduce: item.canReduce
                }
              })
              that.form.solutionListName = resa.map(item => {
                return {
                  solutionName: item.solutionName,
                  canAdd: item.canAdd,
                  canReduce: item.canReduce
                }
              })
              console.log(that.form)
              that.visible = true
            })
        })
    },
    callback () {
      this.getDetail()
      this.$emit('success')
      // this.visible = false
    }
  }
}
</script>
<style lang="scss" scoped>