Commit 27cee777 authored by 高宇's avatar 高宇

完成销售合同;

parent d83b3ce2
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
<el-progress :percentage="progress" v-if="progress > 0 && progress < 100"></el-progress> <el-progress :percentage="progress" v-if="progress > 0 && progress < 100"></el-progress>
</div> </div>
</el-upload> </el-upload>
<span class="tips"><em>{{tips}}</em></span> <span class="tips">{{tips}}
<span class="text-danger">当有新文件上传时, 之前上传的文件将会被删除</span></span>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<slot name="formError"></slot> <slot name="formError"></slot>
......
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
</template> </template>
<script> <script>
// import { import {
// requestAPI, requestAPI,
// api api
// } from '@/lib/commonMixin' } from '@/lib/commonMixin'
import operationContract from './operationContract' import operationContract from './operationContract'
// import {setModule} from '../../../lib/viewHelper' import {setModule} from '../../../lib/viewHelper'
export default { export default {
name: '', name: '',
components: { components: {
...@@ -32,7 +32,20 @@ ...@@ -32,7 +32,20 @@
methods: { methods: {
saveContract () { saveContract () {
let form = this.$refs.operationContract.getForm() let form = this.$refs.operationContract.getForm()
console.log(form) let subData = setModule(form.SalesContracts, 'SalesContracts')
requestAPI(api.saveContractAdd, {
data: {...subData}
}).then(res => {
this.$message({
message: '保存成功!',
type: 'success'
})
this.close(true)
}, error => {
error.msg.forEach(item => {
this.$set(this.errorData, item.name, item.error)
})
})
}, },
close (getList) { close (getList) {
this.$emit('close', getList) this.$emit('close', getList)
......
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
</template> </template>
<script> <script>
// import { import {
// requestAPI, requestAPI,
// api api
// } from '@/lib/commonMixin' } from '@/lib/commonMixin'
import operationContract from './operationContract' import operationContract from './operationContract'
// import {setModule} from '../../../lib/viewHelper' import {setModule} from '../../../lib/viewHelper'
export default { export default {
name: '', name: '',
components: { components: {
...@@ -30,7 +30,23 @@ ...@@ -30,7 +30,23 @@
} }
}, },
methods: { methods: {
saveContract () {}, saveContract () {
let form = this.$refs.operationContract.getForm()
let subData = setModule(form.SalesContracts, 'SalesContracts')
requestAPI(api.saveContractEdit, {
data: {...subData}
}).then(res => {
this.$message({
message: '保存成功!',
type: 'success'
})
this.close(true)
}, error => {
error.msg.forEach(item => {
this.$set(this.errorData, item.name, item.error)
})
})
},
close (getList) { close (getList) {
this.$emit('close', getList) this.$emit('close', getList)
}, },
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
<el-form-item :show-message="false" :error="errorData['contract_scan'] ? errorData['contract_scan'] : ''"> <el-form-item :show-message="false" :error="errorData['contract_scan'] ? errorData['contract_scan'] : ''">
<single-upload <single-upload
label="上传合同" label="上传合同"
tips="只能上传 jpg,png,pdf 类型文件, 文件不能超过50M, 当有新文件上传时, 之前上传的文件将会被删除" tips="只能上传 jpg,png,pdf 类型文件, 文件不能超过50M"
:form-item="SalesContracts.contract_scan" :form-item="SalesContracts.contract_scan"
:file-name="getFileName('contractScan')" :file-name="getFileName('contractScan')"
@update:item="val => {SalesContracts.contract_scan = val}"> @update:item="val => {SalesContracts.contract_scan = val}">
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
<single-upload <single-upload
label="上传签收单" label="上传签收单"
:file-name="getFileName('receiptScan')" :file-name="getFileName('receiptScan')"
tips="只能上传 jpg,png,pdf 类型文件, 文件不能超过50M, 当有新文件上传时, 之前上传的文件将会被删除" tips="只能上传 jpg,png,pdf 类型文件, 文件不能超过50M"
:form-item="SalesContracts.receipt_scan" :form-item="SalesContracts.receipt_scan"
@update:item="val => {SalesContracts.receipt_scan = val}"> @update:item="val => {SalesContracts.receipt_scan = val}">
<span slot="formError" class="el-form-item__error"> <span slot="formError" class="el-form-item__error">
...@@ -259,7 +259,7 @@ ...@@ -259,7 +259,7 @@
description: '', description: '',
contract_scan: '', contract_scan: '',
receipt_scan: '', receipt_scan: '',
contract_type: 2, contract_type: 1,
project_id: '', project_id: '',
// 服务截止 // 服务截止
expire_date: '', expire_date: '',
...@@ -379,10 +379,7 @@ ...@@ -379,10 +379,7 @@
initAdd () { initAdd () {
requestAPI(api.getContractNewOptions).then(res => { requestAPI(api.getContractNewOptions).then(res => {
Object.keys(res.options).forEach(key => { Object.keys(res.options).forEach(key => {
console.log(this.options[key], key) this.$set(this.options, key, res.options[key])
// res.options[key].value.forEach(i => {
// this.options[key].value.push(i)
// })
}) })
}) })
}, },
...@@ -392,12 +389,23 @@ ...@@ -392,12 +389,23 @@
id id
} }
}).then(res => { }).then(res => {
if (res.model.client) {
Object.keys(res.model.client).forEach(item => {
this.$set(this.client, item, res.model.client[item])
})
}
this.options['SalesContracts[project_id]'].value.push(res.model.project)
this.searchText = this.client.name
Object.keys(res.options).forEach(key => { Object.keys(res.options).forEach(key => {
this.$set(this.options, key, res.options[key]) this.$set(this.options, key, res.options[key])
}) })
Object.keys(this.SalesContracts).forEach(item => { Object.keys(this.SalesContracts).forEach(item => {
this.SalesContracts[item] = res.model[item] this.SalesContracts[item] = res.model[item]
}) })
Object.keys(this.files).forEach(item => {
this.files[item].name = res.model[item].orig_name
})
console.log(this.files)
}) })
} }
}, },
......
...@@ -33,6 +33,8 @@ export let setModule = (obj, key, options) => { ...@@ -33,6 +33,8 @@ export let setModule = (obj, key, options) => {
} else { } else {
ob[key + '[' + item + '][' + arr.key + ']'] = arr.name ob[key + '[' + item + '][' + arr.key + ']'] = arr.name
} }
} else if (arr.name) {
ob[key + '[' + item + '][' + arr.name + ']'] = arr.value
} else if (Object.keys(arr).length > 0) { } else if (Object.keys(arr).length > 0) {
Object.keys(arr).forEach(i => { Object.keys(arr).forEach(i => {
ob[key + '[' + item + '][' + i + ']'] = arr[i] ob[key + '[' + item + '][' + i + ']'] = arr[i]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment