Blame view

src/views/workFlow/workFlowForm/mixin.js 2.91 KB
4424f41c   monkeyhouyi   网信执法、清单管理静态页面
1
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
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
  import { mapGetters } from "vuex"
  import { Info } from '@/api/workFlow/workFlowForm'
  import { BillNumber } from '@/api/system/billRule'
  
  export default {
    computed: {
      ...mapGetters(['userInfo']),
    },
    data() {
      return {
        flowUrgentOptions: [{ value: 1, label: '普通' }, { value: 2, label: '重要' }, { value: 3, label: '紧急' }],
        fileList: [],
        setting: {},
        eventType: '',
        loading: false,
      }
    },
    methods: {
      init(data) {
        this.dataForm.id = data.id || ''
        this.setting = data
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.beforeInit) this.beforeInit()
          if (data.id) {
            if (this.selfGetInfo && typeof this.selfGetInfo === "function") return this.selfGetInfo()
            Info(this.setting.enCode, data.id).then(res => {
              this.dataForm = res.data
              if (res.data.fileJson) {
                this.fileList = JSON.parse(res.data.fileJson)
              }
              this.$emit('setPageLoad')
            })
          } else {
            this.dataForm.flowId = data.flowId
            if (this.selfInit) this.selfInit(data)
            if (!this.billEnCode) return this.$emit('setPageLoad')
            BillNumber(this.billEnCode).then(res => {
              if (data.enCode === 'crmOrder') {
                this.dataForm.orderCode = res.data
              } else {
                this.dataForm.billNo = res.data
              }
              this.$emit('setPageLoad')
            })
          }
        })
      },
      getPaymentMethodOptions() {
        this.$store.dispatch('base/getDictionaryData', { sort: 'WFSettlementMethod' }).then((res) => {
          this.paymentMethodOptions = res
        })
      },
      dataFormSubmit(eventType) {
        this.eventType = eventType
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            if (this.exist && !this.exist()) return
            if ('fileJson' in this.dataForm) {
              this.dataForm.fileJson = JSON.stringify(this.fileList)
            }
            if (eventType === 'save' || eventType === 'submit') {
              if (this.selfSubmit && typeof this.selfSubmit === "function") {
                this.selfSubmit(this.dataForm)
                return
              }
            }
            this.$emit('eventReciver', this.dataForm, eventType)
          }
        })
      },
      judgeShow(id) {
        if (this.setting.opType == 4) return true
        if (!this.setting.formOperates || !this.setting.formOperates.length) return true
        let arr = this.setting.formOperates.filter(o => o.id === id) || []
        if (!arr.length) return true
        let item = arr[0]
        return item.read
      },
      judgeWrite(id) {
        if (this.setting.readonly) return true
        if (!this.setting.formOperates || !this.setting.formOperates.length) return false
        let arr = this.setting.formOperates.filter(o => o.id === id) || []
        if (!arr.length) return true
        let item = arr[0]
        return !item.write
      }
    }
  }