浏览代码

景聚庭-挂账人添加流程

huangguoce 9 小时之前
父节点
当前提交
9c9b0f1908

+ 16 - 1
src/api/psi/CreditCustomerService.js

@@ -1,4 +1,4 @@
-import request from "@/utils/httpRequest";
+import request from "@/utils/httpRequest";
 import { PSI_MANAGEMANT as prefix } from "../AppPath";
 
 export default class CreditCustomerService {
@@ -16,6 +16,20 @@ export default class CreditCustomerService {
 			data: param,
 		});
 	}
+	saveFlow(param) {
+		return request({
+			url: prefix + "/psi/creditCustomer/saveFlow",
+			method: "post",
+			data: param,
+		});
+	}
+	updateStatusById(data) {
+		return request({
+			url: prefix + "/psi/creditCustomer/updateStatusById",
+			method: "post",
+			data,
+		});
+	}
 	findById(id) {
 		return request({
 			url: prefix + "/psi/creditCustomer/findById",
@@ -38,3 +52,4 @@ export default class CreditCustomerService {
 		});
 	}
 }
+

+ 76 - 12
src/views/psiManagement/dishManage/creditCustomer/CreditCustomer.vue

@@ -1,4 +1,4 @@
-<template>
+<template>
 	<div class="page">
 		<el-form :inline="true" v-if="searchVisible" class="query-form m-b-10" ref="searchForm" :model="searchForm"
 			@keyup.enter.native="refreshList()" @submit.native.prevent>
@@ -28,7 +28,8 @@
 				<template #buttons>
 					<el-button v-if="hasPermission('psi:creditCustomer:add')" type="primary" icon="el-icon-plus"
 						@click="add()">新建</el-button>
-					<el-button v-if="hasPermission('psi:creditCustomer:del')" type="danger" icon="el-icon-delete" @click="del()"
+					<el-button v-if="hasPermission('psi:creditCustomer:del')" type="danger" icon="el-icon-delete"
+						@click="del()"
 						:disabled="$refs.creditCustomerTable && $refs.creditCustomerTable.getCheckboxRecords().length === 0"
 						plain>删除</el-button>
 				</template>
@@ -38,9 +39,9 @@
 				</template>
 			</vxe-toolbar>
 			<div style="height: calc(100% - 90px)">
-				<vxe-table border="inner" auto-resize resizable height="auto" :loading="loading" ref="creditCustomerTable"
-					show-header-overflow show-overflow highlight-hover-row :menu-config="{}" :data="dataList"
-					:checkbox-config="{}">
+				<vxe-table border="inner" auto-resize resizable height="auto" :loading="loading"
+					ref="creditCustomerTable" show-header-overflow show-overflow highlight-hover-row :menu-config="{}"
+					:data="dataList" :checkbox-config="{}">
 					<vxe-column type="seq" width="60" title="序号"></vxe-column>
 					<vxe-column type="checkbox" width="60"></vxe-column>
 					<vxe-column min-width="130" align="center" title="姓名" field="customerName">
@@ -54,7 +55,8 @@
 					<vxe-column min-width="180" align="center" title="公司名称" field="companyName"></vxe-column>
 					<vxe-column width="110" align="center" title="挂账状态" field="creditStatus">
 						<template #default="scope">
-							<el-tag :type="getStatusTagType(scope.row.creditStatus)">{{ getStatusText(scope.row.creditStatus) }}</el-tag>
+							<el-tag :type="getStatusTagType(scope.row.creditStatus)">{{
+								getStatusText(scope.row.creditStatus) }}</el-tag>
 						</template>
 					</vxe-column>
 					<vxe-column width="130" align="right" title="累计欠款金额" field="totalArrearsAmount">
@@ -63,18 +65,30 @@
 					<vxe-column width="120" align="center" title="未结账单数" field="unsettledBillCount"></vxe-column>
 					<vxe-column min-width="170" align="center" title="首次挂账时间" field="firstCreditTime"></vxe-column>
 					<vxe-column min-width="170" align="center" title="最后消费时间" field="lastConsumeTime"></vxe-column>
+					<vxe-column min-width="170" align="center" title="审核状态" field="status">
+						<template #default="scope">
+							<el-button effect="dark"
+								:type="$dictUtils.getDictLabel('cw_status_flag', scope.row.status, '')">
+								{{ $dictUtils.getDictLabel('cw_status', scope.row.status, '未发起') }}
+							</el-button>
+						</template>
+					</vxe-column>
 					<vxe-column min-width="120" align="center" title="录入人" field="createName"></vxe-column>
 					<vxe-column min-width="120" align="center" title="审核人" field="auditorName"></vxe-column>
 					<vxe-column title="操作" width="250px" fixed="right" align="center">
 						<template #default="scope">
 							<el-button v-if="hasPermission('psi:creditCustomer:edit')" text type="primary" size="small"
 								@click="edit(scope.row.id)">修改</el-button>
-							<el-dropdown v-if="hasPermission('psi:creditCustomer:edit')" trigger="click" @command="handleStatusCommand(scope.row, $event)">
-								<el-button text type="primary" size="small">状态<i class="el-icon-arrow-down el-icon--right"></i></el-button>
+							<el-dropdown v-if="hasPermission('psi:creditCustomer:edit')" trigger="click"
+								@command="handleStatusCommand(scope.row, $event)">
+								<el-button text type="primary" size="small">状态<i
+										class="el-icon-arrow-down el-icon--right"></i></el-button>
 								<template #dropdown>
 									<el-dropdown-menu>
-										<el-dropdown-item v-for="item in $dictUtils.getDictList('credit_status')" :key="item.value"
-											:command="item.value" :disabled="scope.row.creditStatus === item.value">{{ item.label }}</el-dropdown-item>
+										<el-dropdown-item v-for="item in $dictUtils.getDictList('credit_status')"
+											:key="item.value" :command="item.value"
+											:disabled="scope.row.creditStatus === item.value">{{ item.label
+											}}</el-dropdown-item>
 									</el-dropdown-menu>
 								</template>
 							</el-dropdown>
@@ -97,6 +111,12 @@
 <script>
 import CreditCustomerService from '@/api/psi/CreditCustomerService'
 import CreditCustomerForm from './CreditCustomerForm'
+import taskService from '@/api/flowable/taskService'
+import processService from '@/api/flowable/processService'
+import pick from 'lodash.pick'
+
+const CREDIT_CUSTOMER_PROCESS_NAME = '景聚庭-新增挂账人'
+const CREDIT_CUSTOMER_FORM_URL = '/psiManagement/dishManage/creditCustomer/CreditCustomerApproval'
 export default {
 	data() {
 		return {
@@ -114,7 +134,9 @@ export default {
 				pageSize: 10,
 				orders: []
 			},
-			loading: false
+			loading: false,
+			processDefinitionAuditId: '',
+			procDefAuditKey: ''
 		}
 	},
 	creditCustomerService: null,
@@ -124,6 +146,11 @@ export default {
 	components: {
 		CreditCustomerForm
 	},
+	computed: {
+		userName() {
+			return this.$store.state.user.name
+		}
+	},
 	mounted() {
 		this.refreshList()
 	},
@@ -132,7 +159,35 @@ export default {
 	},
 	methods: {
 		add() {
-			this.$refs.creditCustomerForm.init('add', '')
+			this.loadProcessDefinition().then(() => {
+				if (this.commonJS.isEmpty(this.processDefinitionAuditId)) {
+					this.$message.error(`未找到流程【${CREDIT_CUSTOMER_PROCESS_NAME}】,请先配置流程`)
+					return
+				}
+				const tabTitle = `发起流程【${CREDIT_CUSTOMER_PROCESS_NAME}】`
+				const processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了[${CREDIT_CUSTOMER_PROCESS_NAME}]`
+				taskService.getTaskDef({
+					procDefId: this.processDefinitionAuditId,
+					status: 'startAndClose'
+				}).then((data) => {
+					this.$router.push({
+						path: '/flowable/task/TaskForm',
+						query: {
+							...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
+							procDefId: this.processDefinitionAuditId,
+							procDefKey: this.procDefAuditKey,
+							status: 'startAndClose',
+							title: tabTitle,
+							formType: '2',
+							formUrl: CREDIT_CUSTOMER_FORM_URL,
+							formTitle: processTitle,
+							businessId: 'false',
+							isShow: false,
+							routePath: this.$route.path
+						}
+					})
+				})
+			})
 		},
 		edit(id) {
 			this.$refs.creditCustomerForm.init('edit', id)
@@ -141,6 +196,7 @@ export default {
 			this.$refs.creditCustomerForm.init('view', id)
 		},
 		refreshList() {
+			this.loadProcessDefinition()
 			this.loading = true
 			this.creditCustomerService.list({
 				'current': this.tablePage.currentPage,
@@ -155,6 +211,14 @@ export default {
 				this.loading = false
 			})
 		},
+		loadProcessDefinition() {
+			return processService.getByName(CREDIT_CUSTOMER_PROCESS_NAME).then((data) => {
+				if (!this.commonJS.isEmpty(data.id)) {
+					this.processDefinitionAuditId = data.id
+					this.procDefAuditKey = data.key
+				}
+			})
+		},
 		currentChangeHandle({ currentPage, pageSize }) {
 			this.tablePage.currentPage = currentPage
 			this.tablePage.pageSize = pageSize

+ 374 - 0
src/views/psiManagement/dishManage/creditCustomer/CreditCustomerApproval.vue

@@ -0,0 +1,374 @@
+<template>
+	<div class="credit-customer-approval-page" v-loading="loading">
+		<el-card shadow="never" class="approval-card">
+			<template #header>
+				<div class="card-header">挂账人信息</div>
+			</template>
+			<el-form :model="inputForm" ref="inputForm" :class="isReadOnly ? 'readonly' : ''" :disabled="isReadOnly"
+				label-width="130px" @submit.native.prevent>
+				<div class="form-section-title">基本信息</div>
+				<el-row :gutter="20">
+					<el-col :span="8">
+						<el-form-item label="姓名" prop="customerName"
+							:rules="[{ required: true, message: '姓名不能为空', trigger: 'blur' }]">
+							<el-input v-model="inputForm.customerName" maxlength="50" placeholder="请输入姓名"></el-input>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="手机号" prop="mobile"
+							:rules="[{ required: true, message: '手机号不能为空', trigger: 'blur' }]">
+							<el-input v-model="inputForm.mobile" maxlength="30" placeholder="请输入手机号"></el-input>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="挂账状态" prop="creditStatus">
+							<el-select v-model="inputForm.creditStatus" placeholder="请选择挂账状态" clearable style="width: 100%">
+								<el-option v-for="item in $dictUtils.getDictList('credit_status')" :key="item.value"
+									:label="item.label" :value="item.value"></el-option>
+							</el-select>
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<el-row :gutter="20">
+					<el-col :span="8">
+						<el-form-item label="生日" prop="birthday">
+							<el-date-picker v-model="inputForm.birthday" type="date" value-format="YYYY-MM-DD"
+								placeholder="请选择生日" style="width: 100%"></el-date-picker>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="身份证号" prop="idCard">
+							<el-input v-model="inputForm.idCard" maxlength="30" placeholder="请输入身份证号"></el-input>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="年龄" prop="age">
+							<el-input-number v-model="inputForm.age" :min="0" :max="150" :precision="0"
+								style="width: 100%"></el-input-number>
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<el-row :gutter="20">
+					<el-col :span="8">
+						<el-form-item label="职业" prop="occupation">
+							<el-input v-model="inputForm.occupation" maxlength="100" placeholder="请输入职业"></el-input>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="公司名称" prop="companyName">
+							<el-input v-model="inputForm.companyName" maxlength="200" placeholder="请输入公司名称"></el-input>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="紧急联系人" prop="emergencyContact">
+							<el-input v-model="inputForm.emergencyContact" maxlength="50" placeholder="请输入紧急联系人"></el-input>
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<el-row :gutter="20">
+					<el-col :span="8">
+						<el-form-item label="紧急联系人电话" prop="emergencyContactPhone">
+							<el-input v-model="inputForm.emergencyContactPhone" maxlength="30" placeholder="请输入紧急联系人电话"></el-input>
+						</el-form-item>
+					</el-col>
+					<el-col :span="16">
+						<el-form-item label="住址" prop="address">
+							<el-input v-model="inputForm.address" maxlength="500" placeholder="请输入住址"></el-input>
+						</el-form-item>
+					</el-col>
+				</el-row>
+
+				<div class="form-section-title">开票信息</div>
+				<el-row :gutter="20">
+					<el-col :span="12">
+						<el-form-item label="抬头" prop="invoiceTitle">
+							<el-input v-model="inputForm.invoiceTitle" maxlength="200" placeholder="请输入开票抬头"></el-input>
+						</el-form-item>
+					</el-col>
+					<el-col :span="12">
+						<el-form-item label="税号" prop="taxNo">
+							<el-input v-model="inputForm.taxNo" maxlength="100" placeholder="请输入税号"></el-input>
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<el-row :gutter="20">
+					<el-col :span="12">
+						<el-form-item label="开户行" prop="bankName">
+							<el-input v-model="inputForm.bankName" maxlength="200" placeholder="请输入开户行"></el-input>
+						</el-form-item>
+					</el-col>
+					<el-col :span="12">
+						<el-form-item label="账号" prop="bankAccount">
+							<el-input v-model="inputForm.bankAccount" maxlength="100" placeholder="请输入账号"></el-input>
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<el-row :gutter="20">
+					<el-col :span="24">
+						<el-form-item label="开票地址电话" prop="invoiceAddressPhone">
+							<el-input v-model="inputForm.invoiceAddressPhone" maxlength="500" placeholder="请输入开票地址电话"></el-input>
+						</el-form-item>
+					</el-col>
+				</el-row>
+
+				<div class="form-section-title">挂账信息</div>
+				<el-row :gutter="20">
+					<el-col :span="8">
+						<el-form-item label="累计欠款金额" prop="totalArrearsAmount">
+							<el-input-number v-model="inputForm.totalArrearsAmount" :min="0" :precision="2"
+								style="width: 100%"></el-input-number>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="未结账单数" prop="unsettledBillCount">
+							<el-input-number v-model="inputForm.unsettledBillCount" :min="0" :precision="0"
+								style="width: 100%"></el-input-number>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="首次挂账时间" prop="firstCreditTime">
+							<el-date-picker v-model="inputForm.firstCreditTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss"
+								placeholder="请选择首次挂账时间" style="width: 100%"></el-date-picker>
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<el-row :gutter="20">
+					<el-col :span="8">
+						<el-form-item label="最后消费时间" prop="lastConsumeTime">
+							<el-date-picker v-model="inputForm.lastConsumeTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss"
+								placeholder="请选择最后消费时间" style="width: 100%"></el-date-picker>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="录入人" prop="createName">
+							<el-input v-model="inputForm.createName" disabled placeholder="保存后自动记录"></el-input>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="审核人" prop="auditorName">
+							<el-input v-model="inputForm.auditorName" disabled placeholder="暂未审核"></el-input>
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<el-row :gutter="20">
+					<el-col :span="24">
+						<el-form-item label="备注" prop="remarks">
+							<el-input v-model="inputForm.remarks" type="textarea" :rows="4" maxlength="500"
+								placeholder="请输入备注" show-word-limit></el-input>
+						</el-form-item>
+					</el-col>
+				</el-row>
+			</el-form>
+		</el-card>
+	</div>
+</template>
+
+<script>
+import CreditCustomerService from '@/api/psi/CreditCustomerService'
+const BUSINESS_TABLE = 'psi_credit_customer'
+
+export default {
+	props: {
+		businessId: {
+			type: String,
+			default: ''
+		},
+		formReadOnly: {
+			type: Boolean,
+			default: false
+		},
+		status: {
+			type: String,
+			default: ''
+		}
+	},
+	data() {
+		return {
+			loading: false,
+			inputForm: this.defaultForm()
+		}
+	},
+	creditCustomerService: null,
+	computed: {
+		isAuditStatus() {
+			return ['audit', 'agreeAndReject'].includes(this.status)
+		},
+		isReadOnly() {
+			return this.isAuditStatus || this.formReadOnly === true || this.formReadOnly === 'true'
+		}
+	},
+	created() {
+		this.creditCustomerService = new CreditCustomerService()
+		this.init()
+	},
+	activated() {
+		this.init()
+	},
+	watch: {
+		businessId() {
+			this.init()
+		}
+	},
+	methods: {
+		defaultForm() {
+			return {
+				customerName: '',
+				mobile: '',
+				birthday: '',
+				idCard: '',
+				age: undefined,
+				occupation: '',
+				companyName: '',
+				address: '',
+				emergencyContact: '',
+				emergencyContactPhone: '',
+				invoiceTitle: '',
+				taxNo: '',
+				bankName: '',
+				bankAccount: '',
+				invoiceAddressPhone: '',
+				creditStatus: '1',
+				totalArrearsAmount: 0,
+				unsettledBillCount: 0,
+				firstCreditTime: '',
+				lastConsumeTime: '',
+				auditorId: '',
+				auditorName: '',
+				createName: '',
+				status: '',
+				remarks: ''
+			}
+		},
+		getBusinessId() {
+			return this.businessId || this.$route.query.businessId || this.$route.query.id || ''
+		},
+		init() {
+			const id = this.getBusinessId()
+			this.inputForm = this.defaultForm()
+			this.$nextTick(() => {
+				this.$refs.inputForm && this.$refs.inputForm.clearValidate()
+			})
+			if (!id || id === 'false') {
+				return
+			}
+			this.loading = true
+			this.$emit('changeLoading', true)
+			this.creditCustomerService.findById(id).then((data) => {
+				this.inputForm = this.recover(this.inputForm, data)
+				this.inputForm.totalArrearsAmount = Number(this.inputForm.totalArrearsAmount || 0)
+				this.inputForm.unsettledBillCount = Number(this.inputForm.unsettledBillCount || 0)
+				this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
+			}).finally(() => {
+				this.loading = false
+				this.$emit('changeLoading', false)
+			})
+		},
+		getKeyWatch() {
+			this.init()
+		},
+		close() {
+			this.$refs.inputForm && this.$refs.inputForm.resetFields()
+			this.inputForm = this.defaultForm()
+		},
+		validateForm() {
+			return new Promise((resolve) => {
+				this.$refs.inputForm.validate((valid) => {
+					resolve(valid)
+				})
+			})
+		},
+		saveForFlow(callback, status = '2') {
+			this.validateForm().then((valid) => {
+				if (!valid) {
+					return
+				}
+				this.loading = true
+				this.$emit('changeLoading', true)
+				this.inputForm.status = status
+				this.creditCustomerService.saveFlow(this.inputForm).then((data) => {
+					this.inputForm.id = data.businessId || this.inputForm.id
+					callback && callback(data.businessTable || BUSINESS_TABLE, this.inputForm.id, this.inputForm)
+				}).finally(() => {
+					this.loading = false
+					this.$emit('changeLoading', false)
+				})
+			})
+		},
+		saveForm(callback) {
+			this.saveForFlow(() => {
+				callback && callback()
+			}, '1')
+		},
+		startForm(callback) {
+			this.saveForFlow(callback, '2')
+		},
+		reapplyForm(callback) {
+			this.saveForFlow(callback, '2')
+		},
+		agreeForm(callback) {
+			this.updateAuditStatus('5', () => {
+				callback && callback(BUSINESS_TABLE, this.getBusinessId(), this.inputForm)
+			})
+		},
+		updateStatusById(type, callback) {
+			const statusMap = {
+				reject: '4',
+				reback: '3',
+				hold: '1'
+			}
+			const status = statusMap[type]
+			if (!status) {
+				callback && callback()
+				return
+			}
+			this.updateAuditStatus(status, callback)
+		},
+		updateAuditStatus(status, callback) {
+			const id = this.inputForm.id || this.getBusinessId()
+			if (!id || id === 'false') {
+				callback && callback()
+				return
+			}
+			this.loading = true
+			this.$emit('changeLoading', true)
+			this.creditCustomerService.updateStatusById({ id, status }).then(() => {
+				this.inputForm.status = status
+				callback && callback()
+			}).finally(() => {
+				this.loading = false
+				this.$emit('changeLoading', false)
+			})
+		}
+	}
+}
+</script>
+
+<style scoped>
+.credit-customer-approval-page {
+	padding: 10px 0 66px;
+	min-height: 100px;
+}
+
+.approval-card {
+	border-radius: 6px;
+}
+
+.card-header {
+	font-size: 15px;
+	font-weight: 600;
+	color: #303133;
+}
+
+.form-section-title {
+	font-size: 14px;
+	font-weight: 600;
+	color: #303133;
+	padding: 4px 0 12px;
+}
+
+.form-section-title:not(:first-child) {
+	margin-top: 8px;
+	border-top: 1px solid #ebeef5;
+	padding-top: 16px;
+}
+</style>

+ 1 - 0
src/views/psiManagement/dishManage/creditCustomer/CreditCustomerForm.vue

@@ -211,6 +211,7 @@ export default {
 				auditorId: '',
 				auditorName: '',
 				createName: '',
+				status: '',
 				remarks: ''
 			}
 		},