Commit e23242cd authored by 高宇's avatar 高宇

完成销售记录功能;

parent a1cad095
......@@ -59,6 +59,9 @@ export default {
getSalesComponent: {
url: '/vue/sales-order/get-product-component'
},
getSalesSerie: {
url: '/vue/sales-order/get-product-serie'
},
// 搜索供应商名称
searchSupplierByName: {
url: '/vue/search/supplier-by-name'
......
......@@ -5,7 +5,7 @@
<span>{{label}}</span>
</el-col>
<el-col :span="14">
<el-input v-model="item" :placeholder="label" :type="type" :rows="rows" size="mini">
<el-input v-model="item" :placeholder="label" :type="type" :rows="rows" size="mini" :disabled="disabled">
<template slot="prepend">
<span v-if="prepend.text !== ''">{{prepend.text}}</span>
<i :class="['fa', prepend.icon]" v-if="prepend.icon !== ''"></i>
......
......@@ -12,7 +12,7 @@
:trigger-on-focus="false"
:fetch-suggestions="querySearchAsync"
placeholder="输入查找客户"
:disabled="singleSearchDisabled"
:disabled="singleSearchDisabled || disabled"
@select="handleSelect"
></el-autocomplete>
</el-col>
......@@ -44,7 +44,7 @@
if (queryString === '') {
return
}
requestAPI(api.searchClientByName, {
requestAPI(api[this.api], {
data: {
name: queryString
}
......
......@@ -5,7 +5,7 @@
<span>{{label}}</span>
</el-col>
<el-col :span="14">
<el-select v-model="item" :placeholder="label" size="mini" @change="selectChange">
<el-select v-model="item" :placeholder="label" size="mini" @change="selectChange" filterable="filterable" :disabled="this.disabled">
<template slot="prefix" v-if="prefix.text !== ''">
{{prefix.text}}
</template>
......
......@@ -6,6 +6,7 @@
:form-serch-item="SalesOrders.client_id"
:form-show-text="searchText"
:set-option="setClientOption"
api="searchClientByName"
label="客户名称"
:single-search-disabled="singleSearchDisabled"
@update:searchItem="val => {SalesOrders.client_id = val}">
......@@ -32,7 +33,7 @@
label="销售日期"
@update:item="val => {SalesOrders.sales_date = val}">
<span slot="formError" class="el-form-item__error">
{{errorData['project_id']}}
{{errorData['sales_date']}}
</span>
</single-date-picker>
</el-form-item>
......@@ -66,7 +67,7 @@
:options-list="getOptions('SalesOrders[expire_remind_ahead]')"
@update:item="val => {SalesOrders.expire_remind_ahead = val}">
<span slot="formError" class="el-form-item__error">
{{errorData['project_id']}}
{{errorData['expire_remind_ahead']}}
</span>
</single-select>
</el-form-item>
......@@ -74,7 +75,7 @@
<multiple-check-group
:check-group-form-item="SalesOrders.remindReceivers"
label="提醒人"
:check-group-options-list="getOptions('SalesOrders[remindReceivers]')"
:check-group-options-list="getOptions('SalesOrders[salesOrderRemindReceivers]')"
@update:item="val => {SalesOrders.remindReceivers = val}">
<span slot="formError" class="el-form-item__error">
{{errorData['remindReceivers']}}
......@@ -140,12 +141,7 @@
option = this.options[this.optionsKey + '[' + key + ']']
}
if (option) {
if (Object.keys(option).length > 0) {
if (Array.isArray(option.value[0])) {
return option.value[0]
}
return option.value
}
return option.value
}
return []
},
......@@ -198,7 +194,7 @@
data: {id}
}).then(res => {
this.searchText = res.model.client.name
this.options['SalesOrders[project_id]'].value = [res.model.project]
this.options['SalesOrders[project_id]'].value.push(res.model.project)
Object.keys(res.options).forEach(key => {
this.$set(this.options, key, res.options[key])
})
......
......@@ -12,11 +12,12 @@
</template>
<script>
// import {
// requestAPI,
// api
// } from '@/lib/commonMixin'
import {
requestAPI,
api
} from '@/lib/commonMixin'
import operationViewSales from './operationViewSales'
import {setModule} from '../../../lib/viewHelper'
export default {
name: '',
components: {
......@@ -28,7 +29,23 @@
}
},
methods: {
saveSalesItem () {},
saveSalesItem () {
let form = this.$refs.operationViewSales.getForm()
let subData = setModule(form.SalesOrderItems, 'SalesOrderItems')
requestAPI(api.saveSalesAddItem, {
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)
})
})
},
init (id) {
this.$refs.operationViewSales.initAdd(id)
},
......
<template>
<div>
</div>
<section>
<operation-view-sales ref="operationViewSales"
type="copy"
:error-data="errorData"
@update:type="type = 'add'">
<span slot="operationBtn">
<el-button type="primary" @click="saveSalesItem" size="mini">保存</el-button>
<el-button @click="close" size="mini">关闭</el-button>
</span>
</operation-view-sales>
</section>
</template>
<script>
import {
requestAPI,
api
} from '@/lib/commonMixin'
import operationViewSales from './operationViewSales'
import {setModule} from '../../../lib/viewHelper'
export default {
name: '',
components: {
operationViewSales
},
data () {
return {}
return {
errorData: {}
}
},
methods: {
init () {}
saveSalesItem () {
let form = this.$refs.operationViewSales.getForm()
delete form.SalesOrderItems.id
let subData = setModule(form.SalesOrderItems, 'SalesOrderItems')
requestAPI(api.saveSalesAddItem, {
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)
})
})
},
init (id) {
this.$refs.operationViewSales.initCopy(id)
},
close (getList) {
this.$emit('close', getList)
}
},
created () {
}
......
<template>
<div>
</div>
<section>
<operation-view-sales ref="operationViewSales"
:type="type"
:error-data="errorData"
@update:type="type = 'add'">
<span slot="operationBtn">
<el-button type="primary" @click="saveSalesItem" size="mini">保存</el-button>
<el-button @click="close" size="mini">关闭</el-button>
</span>
</operation-view-sales>
</section>
</template>
<script>
import {
requestAPI,
api
} from '@/lib/commonMixin'
import operationViewSales from './operationViewSales'
import {setModule} from '../../../lib/viewHelper'
export default {
name: '',
components: {
operationViewSales
},
data () {
return {}
return {
errorData: {},
type: ''
}
},
methods: {
init () {}
saveSalesItem () {
let form = this.$refs.operationViewSales.getForm()
let subData = setModule(form.SalesOrderItems, 'SalesOrderItems')
requestAPI(api.saveSalesEditItem, {
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)
})
})
},
init (id) {
this.$refs.operationViewSales.initEdit(id)
},
close (getList) {
this.$emit('close', getList)
}
},
created () {
}
......
<template>
<div class="sales-view-operation-form auto-template-form">
<el-form ref="form" :model="SalesOrderItems">
<el-form-item :show-message="false" :error="setError('product_type')">
<single-select
:form-item="SalesOrderItems.product_type"
label="产品分类"
:options-list="getOptions('product_type')"
:set-option="key => {setAllOptions(key)}"
@update:item="val => {SalesOrderItems.product_type = val}">
<div class="sales-view-operation-form auto-template-form">
<el-form ref="form" :model="SalesOrderItems">
<el-form-item :show-message="false" :error="setError('product_type')" v-show="setVisibility('product_type', copyDisabled)">
<single-select
:form-item="SalesOrderItems.product_type"
label="产品分类"
:disabled="copyDisabled"
:options-list="getOptions('product_type')"
:set-option="key => {setComponentOptions(key)}"
@update:item="val => {SalesOrderItems.product_type = val}">
<span slot="formError" class="el-form-item__error">
{{errorData['product_type']}}
</span>
</single-select>
</el-form-item>
</el-form>
</div>
</single-select>
</el-form-item>
<el-form-item :show-message="false" :error="setError('product_component')" v-show="setVisibility('product_component', copyDisabled)">
<single-select
:form-item="SalesOrderItems.product_component"
label="类别"
:disabled="copyDisabled"
:options-list="getOptions('product_component')"
:set-option="setSerieOptions"
@update:item="val => {SalesOrderItems.product_component = val}">
<span slot="formError" class="el-form-item__error">
{{errorData['product_component']}}
</span>
</single-select>
</el-form-item>
<el-form-item :show-message="false" :error="setError('product_brand')" v-show="setVisibility('product_brand', copyDisabled)">
<single-select
:form-item="SalesOrderItems.product_brand"
label="品牌"
:disabled="copyDisabled"
:filterable="true"
:options-list="getOptions('product_brand')"
:set-option="setSerieOptions"
@update:item="val => {SalesOrderItems.product_brand = val}">
<span slot="formError" class="el-form-item__error">
{{errorData['product_brand']}}
</span>
</single-select>
</el-form-item>
<el-form-item :show-message="false" :error="setError('product_serie')" v-show="setVisibility('product_serie', copyDisabled)">
<single-select
:form-item="SalesOrderItems.product_serie"
label="系列"
:disabled="copyDisabled"
:options-list="getOptions('product_serie')"
@update:item="val => {SalesOrderItems.product_serie = val}">
<span slot="formError" class="el-form-item__error">
{{errorData['product_serie']}}
</span>
</single-select>
</el-form-item>
<el-form-item :show-message="false" :error="setError('product_misc')" v-show="setVisibility('product_misc', copyDisabled)">
<single-select
:form-item="SalesOrderItems.product_misc"
label="自定义"
:disabled="copyDisabled"
:options-list="getOptions('product_misc')"
@update:item="val => {SalesOrderItems.product_misc = val}">
<span slot="formError" class="el-form-item__error">
{{errorData['product_misc']}}
</span>
</single-select>
</el-form-item>
<el-form-item :show-message="false" :error="setError('product_id')" v-show="setVisibility('product_id', copyDisabled)">
<single-select
:form-item="SalesOrderItems.product_id"
label="产品名称"
:disabled="copyDisabled"
:options-list="getOptions('product_id')"
@update:item="val => {SalesOrderItems.product_id = val}">
<span slot="formError" class="el-form-item__error">
{{errorData['product_id']}}
</span>
</single-select>
</el-form-item>
<el-form-item :show-message="false" :error="setError('pn')" v-show="setVisibility('pn', copyDisabled)">
<single-input
:form-item="SalesOrderItems.pn"
label="PN"
:disabled="copyDisabled"
@update:item="val => {SalesOrderItems.pn = val}">
<span slot="formError" class="el-form-item__error">
{{errorData['pn']}}
</span>
</single-input>
</el-form-item>
<el-form-item :show-message="false" :error="setError('sn')">
<single-input
:form-item="SalesOrderItems.sn"
label="SN"
@update:item="val => {SalesOrderItems.sn = val}">
<span slot="formError" class="el-form-item__error">
{{errorData['sn']}}
</span>
</single-input>
</el-form-item>
<el-form-item :show-message="false" :error="setError('supplier_id')" v-show="setVisibility('supplier_id', copyDisabled)">
<single-search-input
:form-serch-item="SalesOrderItems.supplier_id"
:form-show-text="searchText"
label="供应商"
:disabled="copyDisabled"
api="searchSupplierByName"
:single-search-disabled="singleSearchDisabled"
@update:searchItem="val => {SalesOrderItems.supplier_id = val}">
<span slot="formError" class="el-form-item__error">
{{errorData['supplier_id']}}
</span>
</single-search-input>
</el-form-item>
<el-form-item>
<el-row :gutter="10">
<el-col :offset="4" :span="14">
<slot name="operationBtn">
</slot>
<!--<el-button type="primary" @click="test">测试</el-button>-->
</el-col>
</el-row>
</el-form-item>
</el-form>
</div>
</template>
<script>
......@@ -23,12 +131,14 @@
api
} from '@/lib/commonMixin'
import operationMixins from '../../../lib/operationMixins'
export default {
name: '',
mixins: [operationMixins],
data () {
return {
SalesOrderItems: {
id: '',
pn: '',
sn: '',
product_id: '',
......@@ -39,18 +149,50 @@
product_misc: '',
supplier_id: ''
},
copyDisabled: false,
searchText: '',
singleSearchDisabled: false,
formKey: 'SalesOrderItems',
options: {}
options: {
'SalesOrderItems[product_component]': {
value: []
}
}
}
},
methods: {
setAllOptions (key) {
setVisibility (key, disabled) {
if (this.SalesOrderItems[key] === '' && disabled) {
return false
} else {
return true
}
},
setComponentOptions (key) {
requestAPI(api.getSalesComponent, {
data: {
id: key
product_type: key
}
}).then(res => {
console.log(res)
this.options['SalesOrderItems[product_component]'].value = []
res.forEach(item => {
this.options['SalesOrderItems[product_component]'].value.push(item)
})
})
},
setSerieOptions () {
this.$nextTick(() => {
requestAPI(api.getSalesSerie, {
data: {
product_component: this.SalesOrderItems.product_component,
product_brand: this.SalesOrderItems.product_brand
}
}).then(res => {
this.options['SalesOrderItems[product_serie]'].value = []
res.forEach(item => {
this.options['SalesOrderItems[product_serie]'].value.push(item)
})
})
})
},
setError (error) {
......@@ -80,20 +222,109 @@
}
return []
},
getForm () {
return {SalesOrderItems: this.SalesOrderItems}
},
initAdd (id) {
this.copyDisabled = false
this.SalesOrderItems.id = ''
requestAPI(api.getSalesNewItem).then(res => {
console.log(res)
Object.keys(res.options).forEach(item => {
console.log(res.options[item])
this.$set(this.options, item, res.options[item])
})
})
},
initEdit (id) {
this.copyDisabled = false
requestAPI(api.getSalesEditItem, {
data: {
id
}
}).then(res => {
Object.keys(res.options).forEach(item => {
this.$set(this.options, item, res.options[item])
})
Object.keys(this.SalesOrderItems).forEach(item => {
this.SalesOrderItems[item] = res.model[item]
if (item === 'supplier_id') {
this.searchText = res.model['supplier'].name
}
})
this.$nextTick(() => {
this.$emit('update:type')
})
})
},
initCopy (id) {
this.copyDisabled = true
requestAPI(api.getSalesEditItem, {
data: {
id
}
}).then(res => {
Object.keys(res.options).forEach(item => {
this.$set(this.options, item, res.options[item])
})
Object.keys(this.SalesOrderItems).forEach(item => {
this.SalesOrderItems[item] = res.model[item]
if (item === 'supplier_id') {
this.searchText = res.model['supplier'].name
}
})
this.$nextTick(() => {
this.$emit('update:type')
})
})
}
},
props: ['errorData']
props: ['errorData', 'type'],
watch: {
'SalesOrderItems.product_type' () {
if (this.type === 'add') {
let clearArr = ['product_component', 'product_brand', 'product_serie', 'product_misc', 'product_id']
clearArr.forEach(item => {
this.SalesOrderItems[item] = ''
})
}
},
'SalesOrderItems.product_component' (val) {
if (this.type === 'add') {
let clearArr = ['product_brand', 'product_serie', 'product_misc', 'product_id']
clearArr.forEach(item => {
this.SalesOrderItems[item] = ''
})
}
},
'SalesOrderItems.product_brand' (val) {
if (this.type === 'add') {
let clearArr = ['product_serie', 'product_misc', 'product_id']
clearArr.forEach(item => {
this.SalesOrderItems[item] = ''
})
}
},
'SalesOrderItems.product_serie' (val) {
if (this.type === 'add') {
let clearArr = ['product_misc', 'product_id']
clearArr.forEach(item => {
this.SalesOrderItems[item] = ''
})
}
},
'SalesOrderItems.product_misc' (val) {
if (this.type === 'add') {
let clearArr = ['product_id']
clearArr.forEach(item => {
this.SalesOrderItems[item] = ''
})
}
}
}
}
</script>
<style scoped>
<style>
.auto-template-form .el-input.is-disabled .el-input__inner{
color: #606266;
}
</style>
......@@ -13,7 +13,7 @@
header-align="center"
min-width="10">
<template slot-scope="scope">
{{scope.row.productType ? scope.row.productType.name : '(未设置)'}}
{{scope.row.product_type !== '' ? scope.row.productType.name : '(未设置)'}}
</template>
</el-table-column>
<el-table-column
......@@ -22,7 +22,7 @@
header-align="center"
min-width="10">
<template slot-scope="scope">
{{scope.row.productComponent ? scope.row.productComponent.name : '(未设置)'}}
{{scope.row.product_component !== '' ? scope.row.productComponent.name : '(未设置)'}}
</template>
</el-table-column>
<el-table-column
......@@ -31,7 +31,7 @@
header-align="center"
min-width="10">
<template slot-scope="scope">
{{scope.row.productBrand ? scope.row.productBrand.name : '(未设置)'}}
{{scope.row.product_brand !== '' ? scope.row.productBrand.name : '(未设置)'}}
</template>
</el-table-column>
<el-table-column
......@@ -40,7 +40,7 @@
header-align="center"
min-width="10">
<template slot-scope="scope">
{{scope.row.productSerie ? scope.row.productSerie.name : '(未设置)'}}
{{scope.row.product_serie !== '' ? scope.row.productSerie.name : '(未设置)'}}
</template>
</el-table-column>
<el-table-column
......@@ -49,7 +49,7 @@
header-align="center"
min-width="10">
<template slot-scope="scope">
{{scope.row.productMisc ? scope.row.productMisc.name : '(未设置)'}}
{{scope.row.product_misc !== '' ? scope.row.productMisc.name : '(未设置)'}}
</template>
</el-table-column>
<el-table-column
......@@ -58,7 +58,7 @@
header-align="center"
min-width="10">
<template slot-scope="scope">
{{scope.row.product ? scope.row.product.name : '(未设置)'}}
{{scope.row.product_id !== '' ? scope.row.product.name : '(未设置)'}}
</template>
</el-table-column>
<el-table-column
......@@ -85,7 +85,7 @@
header-align="center"
min-width="10">
<template slot-scope="scope">
{{scope.row.supplier ? scope.row.supplier.name : '(未设置)'}}
{{scope.row.supplier_id !== '' ? scope.row.supplier.name : '(未设置)'}}
</template>
</el-table-column>
<el-table-column
......
......@@ -137,6 +137,9 @@
close (getList) {
this.$refs.sidePopup &&
this.$refs.sidePopup.close()
if (getList) {
this.getList()
}
},
popupClose () {
this.$refs.sidePopup &&
......@@ -179,7 +182,13 @@
value = this.model[item.key].name
this.$set(obj, 'value', value === '' ? '(未设置)' : value)
} else {
value = this.model[item.key]
if (typeof this.model[item.key] === 'object') {
if (Object.keys(this.model[item.key]).length === 0) {
value = ''
}
} else {
value = this.model[item.key]
}
this.$set(obj, 'value', value === '' ? '(未设置)' : value)
}
if (typeof item.styleKey !== 'undefined') {
......
......@@ -101,7 +101,12 @@ export default {
setPrependText: '',
engineerKey: '',
checkGroupFormItem: Array,
singleSearchDisabled: Boolean
singleSearchDisabled: Boolean,
api: String,
filterable: {
type: Boolean,
default: false
}
},
methods: {
handleCheckGroupAll (val, item) {
......
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