<script>
import baseIndex from '../index'
import { units, currencies, allBusinesssegments } from '@/components/business/viewbase'
import { getDictMap } from '@/api/system/dictDetail'
import { getInfoByDockingListMark, expenseConfigList, expenseSave, expenseRemove, expenseBatchUpdate } from '@/api/business/baseConfig/config'
import { getTemplateListListOfValue } from '@/api/business/price/template'
export default {
name: 'freight-configure',
extends: baseIndex,
mixins: [units(), currencies(), allBusinesssegments()],
data() {
return {
formOptions: [
{ label: '评估类型', name: 'assessmentType', element: 'el-select', clearable: true, options: [] },
{ label: '业务板块', name: 'businessSegmentId', element: 'el-cascader', clearable: true, options: [] },
{ label: '费用类型', name: 'transportExpenseType', element: 'el-select', clearable: true, options: [] },
{ label: '生效日期', name: 'beginDate', element: 'el-date-picker-date', type: 'date' },
{ label: '截止日期', name: 'endDate', element: 'el-date-picker-date', type: 'date' }
],
tableColumns: [
{ prop: 'assessmentType', label: '评估类型', width: 140, visible: true, ifEdit: true, type: 'select', options: [], isValue: true, rules: [{ required: true, message: '评估类型不能为空' }] },
{ prop: 'businessSegmentId', label: '业务板块', width: 140, visible: true, ifEdit: true, type: 'cascader', options: [], isValue: true, multiple: true, rules: [{ required: true, message: '业务板块不能为空' }] },
{ prop: 'transportExpenseType', label: '费用类型', width: 140, visible: true, ifEdit: true, type: 'select', options: [], isValue: true, rules: [{ required: true, message: '费用类型不能为空' }] },
{ prop: 'beginDate', label: '生效日期', width: 140, visible: true, ifEdit: true, type: 'date', rules: [{ required: true, message: '生效日期不能为空' }] },
{ prop: 'endDate', label: '截至日期', width: 140, visible: true, ifEdit: true, type: 'date', rules: [{ required: true, message: '截至日期不能为空' }] },
{ prop: 'price', label: '单价', width: 140, visible: true, ifEdit: true, type: 'priceInput2', align: 'right', priceFormat2: true, rules: [{ required: true, message: '单价不能为空' }] },
{ prop: 'taxRate', label: '税率', width: 140, visible: true, ifEdit: true, type: 'percentage', decimalPlaces: 4, percentFormat: true, formatOptions: { notation: 'fixed', precision: 4 }, rules: [{ required: true, message: '税率不能为空' }] },
{ prop: 'settlementCurrencyId', label: '结算币种', width: 140, visible: true, ifEdit: true, type: 'select', options: [], rules: [{ required: true, message: '结算币种不能为空' }] },
{ prop: 'quantityUnitId', label: '数量单位', width: 140, visible: true, ifEdit: true, type: 'select', options: [], rules: [{ required: true, message: '数量单位不能为空' }] }
],
formItemsFields: [
{ label: '生效日期', prop: 'beginDate', type: 'date', rules: [{ required: true, message: '生效日期不能为空' }] },
{ label: '截止日期', prop: 'endDate', type: 'date', rules: [{ required: true, message: '截止日期不能为空' }] },
{ prop: 'price', label: '单价', type: 'priceInput2', rules: [{ required: true, message: '单价不能为空' }] },
{ prop: 'taxRate', label: '税率', type: 'percentage', decimalPlaces: 4, rules: [{ required: true, message: '税率不能为空' }] }
],
defalutValues: {
taxRate: 0
},
apiBase: {
search: async (params) => Promise.resolve(await expenseConfigList(params)),
save: async (params) => Promise.resolve(await expenseSave(params)),
delete: async (params) => Promise.resolve(await expenseRemove(params)),
batchUpdated: async (params) => Promise.resolve(await expenseBatchUpdate(params))
}
}
},
watch: {
units(val) {
if (val?.length) {
this.setFormItemOptionsModify(this.col, 'quantityUnitId', val)
}
},
currencies(val) {
if (val?.length) {
this.setFormItemOptionsModify(this.col, 'settlementCurrencyId', val)
}
},
businesssegmentList(val) {
if (val?.length) {
this.setFormOptions('businessSegmentId', null, val)
this.setFormItemOptionsModify(this.col, 'businessSegmentId', val)
}
}
},
mounted() {
this.$refs.import.uploadObject.action = '/api/masterData/profitConfig/expenseConfigImport'
getTemplateListListOfValue({ configType: 'transportExpenseConfigModel' }).then(({ code, content }) => { if (code === 1) this.templateOptions = content.map(({ id, name }) => ({ id, name })) })
},
methods: {
async setSearchFormOption() {
const { data: { transport_expense_type = [] }} = await getDictMap('transport_expense_type')
this.setFormOptions('transportExpenseType', '', transport_expense_type)
this.setFormItemOptionsModify(this.col, 'transportExpenseType', transport_expense_type)
const { data: assessment_type } = await getInfoByDockingListMark({ dockingMark: 'AssessmentType' })
this.setFormOptions('assessmentType', '', assessment_type.map(i => ({ ...i, label: i.codeName })))
this.setFormItemOptionsModify(this.col, 'assessmentType', assessment_type.map(i => ({ ...i, label: i.codeName })))
},
otherCheck(row) {
const { beginDate = null, endDate = null } = row
if (new Date(beginDate).getTime() > new Date(endDate).getTime()) {
this.$message.warning('开始时间不能大于结束时间')
return Promise.resolve(false)
}
return Promise.resolve(true)
}
}
}
</script>
//获取
computed: {
editProps() {
return this.tableColumns.filter(i => i.ifEdit).map(i => i.prop)
}
},