|
@@ -1,18 +1,22 @@
|
|
|
<template>
|
|
|
<view class="sop-step">
|
|
|
<u-tabs :list="tabs" :is-scroll="true" :current="current" @change="tabChange"></u-tabs>
|
|
|
- <scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y">
|
|
|
+ <scroll-view scroll-y="true" class="scroll-Y">
|
|
|
<view class="main">
|
|
|
<!-- <u-button class="premission-button" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">授权登录</u-button> -->
|
|
|
<RadiusCell title="SOP各协作项目角色说明" @click="showPopup1 = true"></RadiusCell>
|
|
|
<RadiusCell title="项目派单信息" @click="showPopup2 = true"></RadiusCell>
|
|
|
<view class="form-wrap">
|
|
|
- <u-form :model="formData" ref="form">
|
|
|
+ <u-form :model="formData" ref="uForm">
|
|
|
<MyFormItem :config="config" @change="itemValueChange" v-for="config in curFormConfig" :key="config.formName"></MyFormItem>
|
|
|
</u-form>
|
|
|
</view>
|
|
|
</view>
|
|
|
</scroll-view>
|
|
|
+ <view class="bottom-btns flex justify-between items-center">
|
|
|
+ <u-button :disabled="current + 1 !== setup" class="flex-1" @click="submit('DRAFT')">保存草稿</u-button>
|
|
|
+ <u-button :disabled="current + 1 !== setup" class="flex-1 m-l-30rpx" type="primary" @click="submit('START')">提交</u-button>
|
|
|
+ </view>
|
|
|
|
|
|
<u-popup v-model="showPopup1" mode="bottom" :mask-close-able="false" :closeable="true" :border-radius="28">
|
|
|
<view class="popup-box1">
|
|
@@ -48,15 +52,17 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</u-popup>
|
|
|
+ <u-toast ref="uToast" />
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import RadiusCell from '@/components/radius-cell.vue'
|
|
|
- import { getSopFlowView } from '@/api/sop'
|
|
|
+ import { getSopFlowView, sopApproveApi } from '@/api/sop'
|
|
|
import { CUSTOMER_TYPE } from '@/utils/constants'
|
|
|
import testData from './test'
|
|
|
import MyFormItem from '@/components/low-code/my-form-item.vue'
|
|
|
+ import { cloneDeep } from 'lodash-es'
|
|
|
const needValueCodes = [
|
|
|
'NUMBER', //新增
|
|
|
'TEXT',
|
|
@@ -73,6 +79,7 @@
|
|
|
'FILE'
|
|
|
]
|
|
|
const fullWidthCodes = ['TABLE', 'FORM_GROUP_TITLE', 'TEXTAREA', 'ONLY_TITLE', 'DEVICE_OUT_TABLE', 'DEVICE_IN_TABLE']
|
|
|
+ const arrayValueCodes = ['TABLE', 'DEVICE_OUT_TABLE', 'DEVICE_IN_TABLE', 'MULTIPLE_SELECT', 'CHECKBOX', 'FILE']
|
|
|
export default {
|
|
|
name: 'SopStep',
|
|
|
components: { RadiusCell, MyFormItem },
|
|
@@ -81,18 +88,32 @@
|
|
|
CUSTOMER_TYPE,
|
|
|
showPopup1: false,
|
|
|
showPopup2: false,
|
|
|
- flowId: '433300909770932224',
|
|
|
+ flowId: '',
|
|
|
+ taskId: '',
|
|
|
current: 0,
|
|
|
allSteps: [], //流程步骤数组全数据
|
|
|
tabs: [],
|
|
|
crmInfo: {},
|
|
|
formData: {},
|
|
|
- rules: {}
|
|
|
+ rules: {},
|
|
|
+ setup: 0
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
curFormConfig() {
|
|
|
- const formProperty = this.allSteps[this.current]?.formProperty || []
|
|
|
+ const formProperty = (this.allSteps[this.current]?.formProperty || []).map((item) => {
|
|
|
+ if (item.value && typeof item.value === 'string') {
|
|
|
+ try {
|
|
|
+ item.value = JSON.parse(item.value).value
|
|
|
+ } catch {
|
|
|
+ console.log('这个value值不能被JSON.parse解析,估计之前提交的时候没有用value包一层:', item.value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (item.options && typeof item.options === 'string') {
|
|
|
+ item.options = JSON.parse(item.options)
|
|
|
+ }
|
|
|
+ return item
|
|
|
+ })
|
|
|
return formProperty
|
|
|
}
|
|
|
},
|
|
@@ -100,18 +121,35 @@
|
|
|
curFormConfig(val) {
|
|
|
this.formData = val.reduce((obj, item) => {
|
|
|
if (needValueCodes.includes(item.code)) {
|
|
|
- obj[item.formName] = ''
|
|
|
+ obj[item.formName] = item.value || ''
|
|
|
}
|
|
|
return obj
|
|
|
}, {})
|
|
|
this.rules = val.reduce((obj, item) => {
|
|
|
+ let ruleMap = {
|
|
|
+ DATE: {
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ return this.$u.test.number(value)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ARRAY: {
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ return Array.isArray(value) && value.length
|
|
|
+ },
|
|
|
+ message: item.code === 'FILE' ? '请上传图片' : '请至少填写一项'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let extentsRule = ruleMap[arrayValueCodes.includes(item.code) ? 'ARRAY' : item.code] || { required: true }
|
|
|
let ruleItem =
|
|
|
item.required && needValueCodes.includes(item.code)
|
|
|
- ? {
|
|
|
- required: true,
|
|
|
- message: `${item.title}不能为空`,
|
|
|
- trigger: 'change'
|
|
|
- }
|
|
|
+ ? Object.assign(
|
|
|
+ {},
|
|
|
+ {
|
|
|
+ message: `${item.title}不能为空`,
|
|
|
+ trigger: 'change'
|
|
|
+ },
|
|
|
+ extentsRule
|
|
|
+ )
|
|
|
: null
|
|
|
if (ruleItem) {
|
|
|
obj[item.formName] = [ruleItem]
|
|
@@ -124,6 +162,60 @@
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ submit(approve = 'START') {
|
|
|
+ // const formProperties = cloneDeep(this.curFormConfig)
|
|
|
+ // const formPropertiesValueJsonWithValueKey = formProperties.map((item) => {
|
|
|
+ // item.value = JSON.stringify({ value: this.formData[item.formName] })
|
|
|
+ // if (Array.isArray(item.options)) {
|
|
|
+ // item.options = JSON.stringify(item.options)
|
|
|
+ // }
|
|
|
+ // return item
|
|
|
+ // })
|
|
|
+ // console.log('formPropertiesValueJsonWithValueKey:', formPropertiesValueJsonWithValueKey)
|
|
|
+ // sopApproveApi({
|
|
|
+ // taskId: this.taskId,
|
|
|
+ // formProperties: formPropertiesValueJsonWithValueKey,
|
|
|
+ // setup: this.setup,
|
|
|
+ // approve
|
|
|
+ // }).then(() => {
|
|
|
+ // this.$refs.uToast.show({
|
|
|
+ // title: '填报成功',
|
|
|
+ // type: 'success'
|
|
|
+ // })
|
|
|
+ // this.$Router.back()
|
|
|
+ // })
|
|
|
+ // console.log('rrr', this.rules)
|
|
|
+ this.$refs.uForm.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ console.log('验证通过')
|
|
|
+ console.log('valid:', valid)
|
|
|
+ const formProperties = cloneDeep(this.curFormConfig)
|
|
|
+ const formPropertiesValueJsonWithValueKey = formProperties.map((item) => {
|
|
|
+ item.value = JSON.stringify({ value: this.formData[item.formName] })
|
|
|
+ if (Array.isArray(item.options)) {
|
|
|
+ item.options = JSON.stringify(item.options)
|
|
|
+ }
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ console.log('formPropertiesValueJsonWithValueKey:', formPropertiesValueJsonWithValueKey)
|
|
|
+ sopApproveApi({
|
|
|
+ taskId: this.taskId,
|
|
|
+ formProperties: formPropertiesValueJsonWithValueKey,
|
|
|
+ setup: this.setup,
|
|
|
+ approve
|
|
|
+ }).then(() => {
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ title: '填报成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ this.$Router.back()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log('this.formData:', this.formData)
|
|
|
+ console.log('验证失败')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
getPhoneNumber(e) {
|
|
|
console.log('eee', e)
|
|
|
},
|
|
@@ -132,8 +224,9 @@
|
|
|
},
|
|
|
init() {
|
|
|
getSopFlowView({ flowId: this.flowId }).then((res) => {
|
|
|
- res = { crmInfo: res.crmInfo, ...testData }
|
|
|
+ // res = { crmInfo: res.crmInfo, ...testData }
|
|
|
this.crmInfo = res.crmInfo || {}
|
|
|
+ this.setup = res.currFlowTaskResult?.setup
|
|
|
res.flowTaskHistoryList = res.flowTaskHistoryList || []
|
|
|
res.flowTaskHistoryList.forEach((item) => {
|
|
|
item.formProperty.forEach((v) => {
|
|
@@ -150,15 +243,17 @@
|
|
|
}
|
|
|
]
|
|
|
this.current = this.tabs.length - 1
|
|
|
+ console.log(this.current, this.setup)
|
|
|
})
|
|
|
},
|
|
|
itemValueChange({ prop, value }) {
|
|
|
console.log(prop, ':', value)
|
|
|
- this.formData[prop] = value
|
|
|
+ this.formData[prop] = Array.isArray(value) ? [...value] : value
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
- console.log('query', this.$Route.query)
|
|
|
+ this.flowId = this.$Route.query.flowId
|
|
|
+ this.taskId = this.$Route.query.taskId
|
|
|
this.init()
|
|
|
}
|
|
|
}
|
|
@@ -167,8 +262,18 @@
|
|
|
<style lang="scss" scoped>
|
|
|
.sop-step {
|
|
|
height: 100vh;
|
|
|
+ .bottom-btns {
|
|
|
+ border: 1px solid #d9d9d9;
|
|
|
+ padding: 12rpx 24rpx 50rpx 24rpx;
|
|
|
+ background: #fff;
|
|
|
+ position: fixed;
|
|
|
+ width: 100vw;
|
|
|
+ bottom: 0;
|
|
|
+ left: 0;
|
|
|
+ z-index: 100;
|
|
|
+ }
|
|
|
.scroll-Y {
|
|
|
- height: calc(100% - 88rpx);
|
|
|
+ height: calc(100% - 230rpx);
|
|
|
.main {
|
|
|
padding: 24rpx;
|
|
|
.form-wrap {
|