|
|
@@ -7,56 +7,91 @@
|
|
|
* @FilePath: \opms_frontend\src\views\customer\components\allocate.vue
|
|
|
-->
|
|
|
<template>
|
|
|
- <el-dialog title="提交审核" :visible.sync="visible" width="50%" @close="handleClose">
|
|
|
- <el-form ref="form" label-width="150px" :model="form" :rules="rules">
|
|
|
- <el-form-item label="合同模板" prop="contractModel">
|
|
|
- <el-radio-group v-model="form.contractModel">
|
|
|
- <el-radio label="大数模板" />
|
|
|
- <el-radio label="客户模板" />
|
|
|
- </el-radio-group>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="条款情况" prop="terms">
|
|
|
- <el-radio-group v-model="form.terms">
|
|
|
- <el-radio label="接纳全部条款" />
|
|
|
- <el-radio label="不接纳全部条款" />
|
|
|
- </el-radio-group>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="付款条件" prop="payTerms">
|
|
|
- <el-input
|
|
|
- v-model="form.payTerms"
|
|
|
- maxlength="500"
|
|
|
- placeholder="请输入付款条件"
|
|
|
- resize="none"
|
|
|
- :rows="5"
|
|
|
- show-word-limit
|
|
|
- type="textarea" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="文件" prop="file">
|
|
|
- <el-upload
|
|
|
- ref="uploadRef"
|
|
|
- :action="uploadFileUrl"
|
|
|
- :file-list="fileList"
|
|
|
- :limit="1"
|
|
|
- :show-file-list="true"
|
|
|
- :on-remove="
|
|
|
- (file, fileList) => {
|
|
|
- return removeFile(file, fileList, index)
|
|
|
- }
|
|
|
- "
|
|
|
- :on-success="
|
|
|
- (response, file) => {
|
|
|
- return setFile(response, file, index)
|
|
|
- }
|
|
|
- ">
|
|
|
- <el-button size="mini" type="primary">点击上传</el-button>
|
|
|
- </el-upload>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- <span slot="footer">
|
|
|
- <el-button :loading="loading" size="mini" type="primary" @click="handleSubmit">确定</el-button>
|
|
|
- <el-button size="mini" @click="visible = false">取消</el-button>
|
|
|
- </span>
|
|
|
- </el-dialog>
|
|
|
+ <div>
|
|
|
+ <el-dialog title="提交审核" :visible.sync="visible" width="50%" @close="handleClose">
|
|
|
+ <el-form ref="form" label-width="150px" :model="form" :rules="rules">
|
|
|
+ <el-form-item label="合同模板" prop="contractModel">
|
|
|
+ <el-radio-group v-model="form.contractModel">
|
|
|
+ <el-radio label="大数模板" />
|
|
|
+ <el-radio label="客户模板" />
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="条款情况" prop="terms">
|
|
|
+ <el-radio-group v-model="form.terms">
|
|
|
+ <el-radio label="接纳全部条款" />
|
|
|
+ <el-radio label="不接纳全部条款" />
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="付款条件" prop="payTerms">
|
|
|
+ <el-input
|
|
|
+ v-model="form.payTerms"
|
|
|
+ maxlength="500"
|
|
|
+ placeholder="请输入付款条件"
|
|
|
+ resize="none"
|
|
|
+ :rows="5"
|
|
|
+ show-word-limit
|
|
|
+ type="textarea" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="文件" prop="file">
|
|
|
+ <el-upload
|
|
|
+ ref="uploadRef"
|
|
|
+ :action="uploadFileUrl"
|
|
|
+ :file-list="fileList"
|
|
|
+ :limit="1"
|
|
|
+ :on-remove="
|
|
|
+ (file, fileList) => {
|
|
|
+ return removeFile(file, fileList, index)
|
|
|
+ }
|
|
|
+ "
|
|
|
+ :on-success="
|
|
|
+ (response, file) => {
|
|
|
+ return setFile(response, file, index)
|
|
|
+ }
|
|
|
+ "
|
|
|
+ :show-file-list="true">
|
|
|
+ <el-button size="mini" type="primary">点击上传</el-button>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="shareFlag" label="销售分成">
|
|
|
+ <el-button style="float: right" type="primary" @click="addShare">添加</el-button>
|
|
|
+ <el-table ref="table" :data="shares">
|
|
|
+ <el-table-column label="合同金额" prop="contractAmount" />
|
|
|
+ <el-table-column label="销售" prop="saleId">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-input v-model="row.saleName" readonly suffix-icon="el-icon-search" @focus="handleSelectSale(row)" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="分成比例" prop="shareRatio">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-input-number
|
|
|
+ v-model="row.shareRatio"
|
|
|
+ :max="100"
|
|
|
+ :min="0.01"
|
|
|
+ :precision="2"
|
|
|
+ :step="0.1"
|
|
|
+ @change="changeRatio(row)" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="金额" prop="shareAmount" />
|
|
|
+ <el-table-column align="center" fixed="right" label="操作" width="110px">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button type="primary" @click="deleteShare(scope.$index)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <span slot="footer">
|
|
|
+ <el-button :loading="loading" size="mini" type="primary" @click="handleSubmit">确定</el-button>
|
|
|
+ <el-button size="mini" @click="visible = false">取消</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ <!-- 选择销售工程师弹窗 -->
|
|
|
+ <select-user
|
|
|
+ ref="selectSales"
|
|
|
+ :query-params="{ roles: ['SalesEngineer', 'ProductLineManager'] }"
|
|
|
+ @save="selectSales" />
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
@@ -64,8 +99,10 @@
|
|
|
import { getToken } from '@/utils/token'
|
|
|
import to from 'await-to-js'
|
|
|
import contractApi from '@/api/contract'
|
|
|
+ import SelectUser from '@/components/select/SelectUser'
|
|
|
+
|
|
|
export default {
|
|
|
- components: {},
|
|
|
+ components: { SelectUser },
|
|
|
data() {
|
|
|
return {
|
|
|
visible: false,
|
|
|
@@ -95,10 +132,32 @@
|
|
|
terms: [{ required: true, trigger: 'blur', message: '请选择条款情况' }],
|
|
|
payTerms: [{ required: true, trigger: 'blur', message: '请选择付款条件' }],
|
|
|
},
|
|
|
+ shareFlag: false,
|
|
|
+ theContract: {},
|
|
|
+ shares: [], // 分成计算
|
|
|
+ theShare: {}, // 选中的分成数据
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 打开弹窗
|
|
|
+ openDialog(row) {
|
|
|
+ this.shareFlag = true
|
|
|
+ this.shares.splice(0, this.shares.length)
|
|
|
+ this.theContract = row
|
|
|
+ this.shares.push({
|
|
|
+ contractId: this.theContract.id,
|
|
|
+ contractCode: this.theContract.contractCode,
|
|
|
+ contractAmount: this.theContract.contractAmount,
|
|
|
+ contractSignTime: this.theContract.contractSignTime,
|
|
|
+ saleId: this.theContract.inchargeId,
|
|
|
+ saleName: this.theContract.inchargeName,
|
|
|
+ shareRatio: 100,
|
|
|
+ shareAmount: this.theContract.contractAmount,
|
|
|
+ })
|
|
|
+ this.visible = true
|
|
|
+ },
|
|
|
handleClose() {
|
|
|
+ this.shareFlag = false
|
|
|
this.fileList = []
|
|
|
this.loading = false
|
|
|
this.form = {
|
|
|
@@ -121,73 +180,83 @@
|
|
|
this.form.fileUrl = ''
|
|
|
},
|
|
|
async handleSubmit() {
|
|
|
+ // 数据校验
|
|
|
const [valid] = await to(this.$refs.form.validate())
|
|
|
if (valid == false) return
|
|
|
if (!this.form.fileUrl) return this.$message.warning('附件不能为空')
|
|
|
- // const [err, res] = await to(contractApi.ss(this.form))
|
|
|
- // if (err) return
|
|
|
|
|
|
- this.loading = true
|
|
|
- contractApi
|
|
|
- .commitWithFileUrl(this.form)
|
|
|
- .then((res) => {
|
|
|
- if (res.code == 200) {
|
|
|
- this.$message.success('提交成功')
|
|
|
- this.visible = false
|
|
|
- this.$emit('refresh')
|
|
|
- } else {
|
|
|
- this.$message.success('系统异常')
|
|
|
- console.error(res)
|
|
|
- }
|
|
|
- this.loading = false
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- console.error(err)
|
|
|
- this.loading = false
|
|
|
+ // 销售分成信息校验
|
|
|
+ if (!this.shares || this.shares.length == 0) {
|
|
|
+ return this.$message.warning('分成信息不能为空')
|
|
|
+ }
|
|
|
+ let ratio = 0
|
|
|
+ for (let share of this.shares) {
|
|
|
+ ratio += parseFloat(share.shareRatio)
|
|
|
+ if (share.saleName == '') {
|
|
|
+ return this.$message.warning('销售不能为空')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ratio > 100) {
|
|
|
+ this.$confirm('合计分成比例大于1,确定提交数据吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }).then(async () => {
|
|
|
+ this.loading = true
|
|
|
+ let data = JSON.parse(JSON.stringify(this.form))
|
|
|
+ data.shares = this.shares
|
|
|
+ contractApi
|
|
|
+ .commitWithFileUrl(data)
|
|
|
+ .then((res) => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.$message.success('提交成功')
|
|
|
+ this.visible = false
|
|
|
+ this.$emit('refresh')
|
|
|
+ } else {
|
|
|
+ this.$message.success('系统异常')
|
|
|
+ console.error(res)
|
|
|
+ }
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.error(err)
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
})
|
|
|
-
|
|
|
- // let formData = new FormData()
|
|
|
- // formData.append('file', this.form.file)
|
|
|
- // formData.append('contractId', this.form.id)
|
|
|
- // formData.append('contractModel', this.form.contractModel)
|
|
|
- // formData.append('terms', this.form.terms)
|
|
|
- // formData.append('payTerms', this.form.payTerms)
|
|
|
- // this.loading = true
|
|
|
- // axios({
|
|
|
- // method: 'post',
|
|
|
- // url: process.env.VUE_APP_MicroSrvProxy_API + process.env.VUE_APP_ParentPath,
|
|
|
- // // url: 'http://192.168.0.51:9981/dashoo.dev.opms.parent-0.0.1',
|
|
|
- // data: formData,
|
|
|
- // headers: {
|
|
|
- // Authorization: 'Bearer ' + getToken(),
|
|
|
- // 'X-RPCX-SerializeType': '1',
|
|
|
- // 'X-RPCX-ServicePath': 'CtrContractHandler',
|
|
|
- // 'X-RPCX-ServiceMethod': 'CommitWithFile',
|
|
|
- // 'content-type': 'multipart/form-data',
|
|
|
- // tenant: process.env.VUE_APP_TENANT,
|
|
|
- // },
|
|
|
- // })
|
|
|
- // .then((res) => {
|
|
|
- // this.loading = false
|
|
|
- // console.log(res)
|
|
|
- // if (res.data.code != 0) {
|
|
|
- // this.$message({
|
|
|
- // type: 'error',
|
|
|
- // message: res.data.msg,
|
|
|
- // })
|
|
|
- // } else {
|
|
|
- // this.visible = false
|
|
|
- // this.$emit('refresh')
|
|
|
- // }
|
|
|
- // })
|
|
|
- // .catch((err) => {
|
|
|
- // this.loading = false
|
|
|
- // console.error(err)
|
|
|
- // this.$message({
|
|
|
- // type: 'warning',
|
|
|
- // message: '系统异常',
|
|
|
- // })
|
|
|
- // })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 修改分成比例
|
|
|
+ changeRatio(row) {
|
|
|
+ row.shareAmount = (row.contractAmount * row.shareRatio) / 100
|
|
|
+ },
|
|
|
+ // 添加分成信息
|
|
|
+ addShare() {
|
|
|
+ this.shares.push({
|
|
|
+ contractId: this.theContract.id,
|
|
|
+ contractCode: this.theContract.contractCode,
|
|
|
+ contractAmount: this.theContract.contractAmount,
|
|
|
+ contractSignTime: this.theContract.contractSignTime,
|
|
|
+ saleId: '',
|
|
|
+ saleName: '',
|
|
|
+ shareRatio: 1,
|
|
|
+ shareAmount: this.theContract.contractAmount / 100,
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 删除分成信息
|
|
|
+ deleteShare(index) {
|
|
|
+ this.shares.splice(index, 1)
|
|
|
+ },
|
|
|
+ // 选择销售
|
|
|
+ handleSelectSale(row) {
|
|
|
+ this.theShare = row
|
|
|
+ this.$refs.selectSales.open()
|
|
|
+ },
|
|
|
+ // 选中
|
|
|
+ selectSales(val) {
|
|
|
+ if (val && val.length > 0) {
|
|
|
+ this.theShare.saleId = val[0].id
|
|
|
+ this.theShare.saleName = val[0].nickName
|
|
|
+ }
|
|
|
},
|
|
|
},
|
|
|
}
|