zjf
2023-02-24 2126cd24b8a0174ac0597340917c0a4595f72254
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<template>
  <div>
    <el-form
      v-if="examineInfo.examineType === 2"
      ref="form"
      :model="form"
      :rules="rules"
      label-position="top"
      class="crm-create-box">
      <el-form-item
        prop="name"
        class="crm-create-item">
        <div
          slot="label"
          style="display: inline-block;">
          <div style="margin:5px 0;font-size:12px;word-wrap:break-word;word-break:break-all;">
            审核人
            <span style="color:#999;"/>
          </div>
        </div>
        <xh-user-cell
          :info-type="types"
          :value="draftUser ? [draftUser] : []"
          @value-change="fieldValueChange"/>
      </el-form-item>
    </el-form>
    <flexbox
      v-else-if="examineInfo.examineType === 1"
      class="fixed-examine"
      wrap="wrap">
      <el-popover
        v-for="(item, index) in examineInfo.examineSteps"
        :key="index"
        :disabled="item.userList.length==0"
        :content="item.userList|contentFilters"
        placement="bottom"
        trigger="hover">
        <div
          slot="reference"
          class="fixed-examine-item">
          <img src="@/assets/img/examine_head.png" >
          <div class="detail">{{ item|detail }}</div>
          <div class="step">{{ (index+1)|step }}</div>
        </div>
      </el-popover>
    </flexbox>
 
  </div>
</template>
<script type="text/javascript">
// import { crmCreateExamineFlow } from '@/api/clients/common'
// import { oaCreateExamineFlow } from '@/api/oamanagement/examine'
 
import { XhUserCell } from '@/components/CreateCom'
// import Nzhcn from 'nzh/cn'
 
export default {
  name: 'CreateExamineInfo',
  components: {
    XhUserCell
  },
  filters: {
    detail: function (data) {
      if (data.stepType === 2) {
        return data.userList.length + '人或签'
      } else if (data.stepType === 3) {
        return data.userList.length + '人会签'
      } else if (data.stepType === 1) {
        return '负责人主管'
      } else if (data.stepType === 4) {
        return '上一级审批人主管'
      }
    },
    step: function (index) {
      // return '第' + Nzhcn.encodeS(index) + '级'
    },
    contentFilters: function (array) {
      return array
        .map(item => {
          return item.realname
        })
        .join('、')
    }
  },
  props: {
    // CRM类型
    types: {
      type: String,
      default: ''
    },
    // 办公审批 传ID
    typesId: {
      type: [String, Number],
      default: ''
    }
  },
  data () {
    return {
      form: {
        name: ''
      },
      rules: {
        name: [{ required: true, message: '审批人不能为空', trigger: 'blur' }]
      },
      // 审核信息 examineType 1 固定审批 2 授权审批
      examineInfo: {},
      draftUser: null
    }
  },
  computed: {},
  mounted () {
    this.getDetail()
  },
  methods: {
    getDetail () {
      // const reqeust = {
      //   oa_examine: oaCreateExamineFlow,
      //   crm_contract: crmCreateExamineFlow,
      //   crm_receivables: crmCreateExamineFlow
      // }[this.types]
 
      const params = {}
      if (this.types === 'oa_examine') {
        params.categoryId = this.typesId
      } else {
        params.id = this.typesId
        params.categoryType = this.types === 'crm_contract' ? 1 : 2 // 1 合同 2 回款
      }
      // reqeust(params)
      //   .then(res => {
      //     this.examineInfo = res.data
      //     if (res.data.examineType === 2 && res.data.examineUser) {
      //       this.draftUser = {
      //         realname: res.data.examineUserName,
      //         userId: res.data.examineUser
      //       }
      //       this.form.name = res.data.examineUserName
      //       this.$emit('value-change', {
      //         examineType: res.data.examineType, // 审批类型
      //         value: [this.draftUser] // 审批信息
      //       })
      //     } else {
      //       this.form.name = ''
      //       this.draftUser = null
      //       this.$emit('value-change', {
      //         examineType: res.data.examineType, // 审批类型
      //         value: [] // 审批信息
      //       })
      //     }
      //   })
      //   .catch(() => {})
    },
    validateField (result) {
      if (this.examineInfo.examineType === 2) {
        // 授权审批人 需要验证关联人
        this.$refs.form.validate(valid => {
          if (valid) {
            result() // 成功回调
          } else {
            return false
          }
        })
      } else {
        result() // 成功回调
      }
    },
    // 字段的值更新
    fieldValueChange (data) {
      if (data.value.length) {
        this.draftUser = data.value[0]
        this.form.name = this.draftUser.userId
      } else {
        this.draftUser = null
        this.form.name = ''
      }
      this.$emit('value-change', {
        examineType: this.examineInfo.examineType, // 审批类型
        value: data.value // 审批信息
      })
      this.$refs.form.validateField('name')
    }
  }
}
</script>
<style lang="less" scoped>
/** 将其改变为flex布局 */
.crm-create-box {
  display: flex;
  flex-wrap: wrap;
  padding: 0 10px;
}
 
.crm-create-item {
  flex: 0 0 45%;
  flex-shrink: 0;
  // overflow: hidden;
  padding-bottom: 10px;
}
 
.el-form-item /deep/ .el-form-item__label {
  line-height: normal;
  font-size: 13px;
  color: #333333;
  position: relative;
  padding-left: 8px;
  padding-bottom: 0;
}
 
.el-form /deep/ .el-form-item {
  margin-bottom: 0px;
}
 
.el-form /deep/ .el-form-item.is-required .el-form-item__label:before {
  content: '*';
  color: #f56c6c;
  margin-right: 4px;
  position: absolute;
  left: 0;
  top: 5px;
}
 
// 固定审批信息
.fixed-examine {
  padding: 0px 10px;
  text-align: center;
  .fixed-examine-item {
    padding: 10px 20px;
    img {
      width: 40px;
      height: 40px;
    }
    .detail {
      color: #777777;
      font-size: 12px;
      padding: 2px 0;
      transform: scale(0.8, 0.8);
    }
    .step {
      color: #333333;
      font-size: 12px;
    }
  }
}
</style>