|
@@ -0,0 +1,492 @@
|
|
|
+import { required } from '@/components/template/rules_verify.js'
|
|
|
+import {
|
|
|
+ orderBaseProductList,
|
|
|
+ orderBaseProductAdd,
|
|
|
+ orderBaseProductUpdate,
|
|
|
+ orderBaseProductDelete
|
|
|
+} from '@/api/workOrderPool.js'
|
|
|
+import { serviceCategoryList, serviceCategoryListSpec, serviceCategoryListMinus } from '@/api/recycleCategoryCenter.js'
|
|
|
+import { listToTree } from '@/utils/util'
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ isEditIndex_hs: -1,
|
|
|
+ serviceCategoryListData: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ hs_productColumns() {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ columnAttributes: {
|
|
|
+ label: '回收类目',
|
|
|
+ prop: 'bigId' //bigName
|
|
|
+ },
|
|
|
+ render: (h, { row, column, index }) => {
|
|
|
+ return this.isEditIndex_hs == index ? (
|
|
|
+ <div class="redbordererr">
|
|
|
+ <el-form-item
|
|
|
+ label=""
|
|
|
+ label-width="0px"
|
|
|
+ prop={`orderProducts.${index}.${column.columnAttributes.prop}`}
|
|
|
+ rules={[...required]}
|
|
|
+ >
|
|
|
+ <el-select
|
|
|
+ disabled={!this.formOptions.orderProducts.isEdit}
|
|
|
+ value={row[column.columnAttributes.prop]}
|
|
|
+ onInput={val => {
|
|
|
+ row[column.columnAttributes.prop] = val
|
|
|
+ }}
|
|
|
+ onChange={val => {
|
|
|
+ row.bigName = this.serviceCategoryListData.find(item => item.id == val)?.name || ''
|
|
|
+ row.mainId = ''
|
|
|
+ row.mainName = ''
|
|
|
+ row.productId = ''
|
|
|
+ row.productName = ''
|
|
|
+ row.num = ''
|
|
|
+ row.estimatePrice = ''
|
|
|
+ row.serviceAmount = ''
|
|
|
+ row.pgOrderProductRecycles = []
|
|
|
+ this.jisuanjiage(row, index)
|
|
|
+ }}
|
|
|
+ placeholder="请选择"
|
|
|
+ >
|
|
|
+ {this.serviceCategoryListData.map((item, index_) => (
|
|
|
+ <el-option key={index_} label={item.name} value={item.id}></el-option>
|
|
|
+ ))}
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ ) : (
|
|
|
+ <div style="padding-left:10px">{row.brandName}</div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ columnAttributes: {
|
|
|
+ label: '产品大类',
|
|
|
+ prop: 'mainId' //mainName
|
|
|
+ },
|
|
|
+ render: (h, { row, column, index }) => {
|
|
|
+ return this.isEditIndex_hs == index ? (
|
|
|
+ <div class="redbordererr">
|
|
|
+ <el-form-item
|
|
|
+ label=""
|
|
|
+ label-width="0px"
|
|
|
+ prop={`orderProducts.${index}.${column.columnAttributes.prop}`}
|
|
|
+ rules={[...required]}
|
|
|
+ >
|
|
|
+ <el-select
|
|
|
+ disabled={!this.formOptions.orderProducts.isEdit}
|
|
|
+ value={row[column.columnAttributes.prop]}
|
|
|
+ onInput={val => {
|
|
|
+ row[column.columnAttributes.prop] = val
|
|
|
+ }}
|
|
|
+ onChange={val => {
|
|
|
+ row.mainName =
|
|
|
+ (this.serviceCategoryListData.find(item => item.id == row?.bigId)?.children || []).find(
|
|
|
+ item => item.id == val
|
|
|
+ )?.name || ''
|
|
|
+ row.productId = ''
|
|
|
+ row.productName = ''
|
|
|
+ row.num = ''
|
|
|
+ row.estimatePrice = ''
|
|
|
+ row.serviceAmount = ''
|
|
|
+ row.pgOrderProductRecycles = []
|
|
|
+ this.jisuanjiage(row, index)
|
|
|
+ }}
|
|
|
+ placeholder="请选择"
|
|
|
+ >
|
|
|
+ {(this.serviceCategoryListData.find(item => item.id == row?.bigId)?.children || []).map(
|
|
|
+ (item, index_) => (
|
|
|
+ <el-option key={index_} label={item.name} value={item.id}></el-option>
|
|
|
+ )
|
|
|
+ )}
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ ) : (
|
|
|
+ <div style="padding-left:10px">{row.mainName}</div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ columnAttributes: {
|
|
|
+ label: '产品规格',
|
|
|
+ prop: 'productId' //productName
|
|
|
+ },
|
|
|
+ render: (h, { row, column, index }) => {
|
|
|
+ return this.isEditIndex_hs == index ? (
|
|
|
+ <div class="redbordererr">
|
|
|
+ <el-form-item
|
|
|
+ label=""
|
|
|
+ label-width="0px"
|
|
|
+ prop={`orderProducts.${index}.${column.columnAttributes.prop}`}
|
|
|
+ rules={[...required]}
|
|
|
+ >
|
|
|
+ <el-select
|
|
|
+ disabled={!this.formOptions.orderProducts.isEdit}
|
|
|
+ value={row[column.columnAttributes.prop]}
|
|
|
+ onInput={val => {
|
|
|
+ row[column.columnAttributes.prop] = val
|
|
|
+ }}
|
|
|
+ onChange={val => {
|
|
|
+ row.productName = this.serviceCategoryListSpecData.find(
|
|
|
+ item => item.serviceCategoryItemId == val
|
|
|
+ )?.dictName
|
|
|
+ this.jisuanjiage(row, index)
|
|
|
+ }}
|
|
|
+ placeholder="请选择"
|
|
|
+ >
|
|
|
+ {this.serviceCategoryListSpecData
|
|
|
+ .filter(item => item.mainId === row.mainId)
|
|
|
+ .map((item, index_) => (
|
|
|
+ <el-option key={index_} label={item.dictName} value={item.serviceCategoryItemId}></el-option>
|
|
|
+ ))}
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ ) : (
|
|
|
+ <div style="padding-left:10px">{row.smallName}</div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ columnAttributes: {
|
|
|
+ label: '数量',
|
|
|
+ prop: 'num'
|
|
|
+ },
|
|
|
+ render: (h, { row, column, index }) => {
|
|
|
+ return this.isEditIndex_hs == index ? (
|
|
|
+ <div class="redbordererr">
|
|
|
+ <el-form-item
|
|
|
+ label=""
|
|
|
+ label-width="0px"
|
|
|
+ prop={`orderProducts.${index}.${column.columnAttributes.prop}`}
|
|
|
+ rules={this.orderInfo.isCj ? [] : required}
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ disabled={!this.formOptions.orderProducts.isEdit}
|
|
|
+ value={row[column.columnAttributes.prop]}
|
|
|
+ onInput={val => {
|
|
|
+ row[column.columnAttributes.prop] = val
|
|
|
+ this.jisuanjiage(row, index)
|
|
|
+ }}
|
|
|
+ placeholder="请输入内容"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ ) : (
|
|
|
+ <div style="padding-left:10px">{row[column.columnAttributes.prop]}</div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ columnAttributes: {
|
|
|
+ label: '属性',
|
|
|
+ prop: 'pgOrderProductRecycles'
|
|
|
+ },
|
|
|
+ render: (h, { row, column, index }) => {
|
|
|
+ return this.isEditIndex_hs == index ? (
|
|
|
+ <div class="redbordererr">
|
|
|
+ <el-form-item
|
|
|
+ label=""
|
|
|
+ label-width="0px"
|
|
|
+ prop={`orderProducts.${index}.${column.columnAttributes.prop}`}
|
|
|
+ rules={[...required]}
|
|
|
+ >
|
|
|
+ <el-select
|
|
|
+ disabled={!this.formOptions.orderProducts.isEdit}
|
|
|
+ value={row[column.columnAttributes.prop]}
|
|
|
+ onInput={val => {
|
|
|
+ row[column.columnAttributes.prop] = val
|
|
|
+ }}
|
|
|
+ placeholder="请选择"
|
|
|
+ onChange={val => {
|
|
|
+ this.jisuanjiage(row, index)
|
|
|
+ }}
|
|
|
+ multiple={true}
|
|
|
+ >
|
|
|
+ {this.serviceCategoryListMinusData
|
|
|
+ .filter(item => item.mainId === row.mainId)
|
|
|
+ .map((item, index_) => (
|
|
|
+ <el-option
|
|
|
+ key={index_}
|
|
|
+ label={`${item.categoryName}-${item.dictName}`}
|
|
|
+ value={item.serviceCategoryItemId}
|
|
|
+ ></el-option>
|
|
|
+ ))}
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ ) : (
|
|
|
+ <div style="padding-left:10px">{row.smallName}</div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ columnAttributes: {
|
|
|
+ label: '预估金额(元)',
|
|
|
+ prop: 'estimatePrice'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ columnAttributes: {
|
|
|
+ label: '导购分佣',
|
|
|
+ prop: 'serviceAmount'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ...(() => {
|
|
|
+ if (this.formOptions.orderProducts.isEdit) {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ columnAttributes: {
|
|
|
+ label: '操作'
|
|
|
+ },
|
|
|
+ render: (h, { row, column, index }) => {
|
|
|
+ return (
|
|
|
+ <div style="padding-left:10px">
|
|
|
+ <el-button
|
|
|
+ type="text"
|
|
|
+ onClick={() => {
|
|
|
+ this.delProduct_hs(row, index)
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </el-button>
|
|
|
+ {this.isEditIndex_hs == index && (
|
|
|
+ <el-button
|
|
|
+ type="text"
|
|
|
+ onClick={() => {
|
|
|
+ this.eidtProduct_hs(row, index)
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 确定
|
|
|
+ </el-button>
|
|
|
+ )}
|
|
|
+ {this.isEditIndex_hs == -1 && (
|
|
|
+ <el-button
|
|
|
+ type="text"
|
|
|
+ onClick={() => {
|
|
|
+ this.isEditIndex_hs = index
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 编辑
|
|
|
+ </el-button>
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ return []
|
|
|
+ })()
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ hs_product() {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ isShow: this.formOptions.orderProducts.isShow,
|
|
|
+ name: 'slot-component',
|
|
|
+ md: 24,
|
|
|
+ formItemAttributes: {
|
|
|
+ label: '',
|
|
|
+ 'label-width': '0px',
|
|
|
+ prop: 'orderProducts',
|
|
|
+ errLabel: '产品信息',
|
|
|
+ rules: this.formOptions.orderProducts.isRules
|
|
|
+ },
|
|
|
+ render: (h, { props }) => {
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ {this.formOptions.orderProducts.isEdit ? (
|
|
|
+ <div>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="primary"
|
|
|
+ onClick={() => {
|
|
|
+ this.appointVerify(this.getVfyKey_hs(this.isEditIndex_hs, false), v => {
|
|
|
+ if (v) {
|
|
|
+ try {
|
|
|
+ this.orderInfo.orderProducts.map((item, index_) => {
|
|
|
+ var row = this.orderInfo.orderProducts[index_ + 1]
|
|
|
+ if (row) {
|
|
|
+ if (
|
|
|
+ `${row.bigId}_${row.mainId}_${row.productId}` ==
|
|
|
+ `${item.bigId}_${item.mainId}_${item.productId}`
|
|
|
+ ) {
|
|
|
+ throw new Error('')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.warning('产品机型重复')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.isEditIndex_hs = 0
|
|
|
+ this.orderInfo.orderProducts.unshift({
|
|
|
+ bigId: '',
|
|
|
+ bigName: '',
|
|
|
+ brandId: '',
|
|
|
+ brandName: '',
|
|
|
+ bugRemark: '',
|
|
|
+ detailRemark: '',
|
|
|
+ estimatePrice: '',
|
|
|
+ giveAddress: '',
|
|
|
+ giveTime: '',
|
|
|
+ imgUrl: '',
|
|
|
+ insideCode: '',
|
|
|
+ isDefend: '',
|
|
|
+ mainId: '',
|
|
|
+ mainName: '',
|
|
|
+ num: '',
|
|
|
+ outCode: '',
|
|
|
+ pgOrderProductRecycles: [],
|
|
|
+ productId: '',
|
|
|
+ productName: '',
|
|
|
+ remark: '',
|
|
|
+ smallId: '',
|
|
|
+ smallName: '',
|
|
|
+ status: '',
|
|
|
+ sumbitAddress: '',
|
|
|
+ workerId: '',
|
|
|
+ workerMobile: '',
|
|
|
+ workerName: '',
|
|
|
+ orderBaseId: this.id || ''
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 新增
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ ) : null}
|
|
|
+ <zj-table columns={this.hs_productColumns} table-data={this.orderInfo.orderProducts} />
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ serviceCategoryList({ pageNum: 1, pageSize: -1, params: [{ param: 'status', compare: '=', value: 'ON' }] }).then(
|
|
|
+ res => {
|
|
|
+ this.serviceCategoryListData = listToTree(res.data.records, 'pid')
|
|
|
+ }
|
|
|
+ )
|
|
|
+ serviceCategoryListSpec({
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: -1,
|
|
|
+ params: [
|
|
|
+ { param: 'type_attribute', compare: '=', value: 'SPEC' },
|
|
|
+ { param: 'status', compare: '=', value: 'ON' }
|
|
|
+ ]
|
|
|
+ }).then(res => {
|
|
|
+ this.serviceCategoryListSpecData = res.data.records
|
|
|
+ })
|
|
|
+ serviceCategoryListMinus({
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: -1,
|
|
|
+ params: [
|
|
|
+ { param: 'type_attribute', compare: '=', value: 'DED' },
|
|
|
+ { param: 'status', compare: '=', value: 'ON' }
|
|
|
+ ]
|
|
|
+ }).then(res => {
|
|
|
+ this.serviceCategoryListMinusData = res.data.records
|
|
|
+ })
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ jisuanjiage(row, index) {
|
|
|
+ var estimatePrice = 0
|
|
|
+ var serviceAmount = 0
|
|
|
+ if (row.productId) {
|
|
|
+ var { servicePrice, price } = this.serviceCategoryListSpecData.find(
|
|
|
+ item => item.serviceCategoryItemId == row.productId
|
|
|
+ )
|
|
|
+ estimatePrice += price * row.num
|
|
|
+ serviceAmount += servicePrice * row.num
|
|
|
+ }
|
|
|
+ if (row?.pgOrderProductRecycles?.length) {
|
|
|
+ this.serviceCategoryListMinusData
|
|
|
+ .filter(item => row.pgOrderProductRecycles.includes(item.serviceCategoryItemId))
|
|
|
+ .map(item => {
|
|
|
+ estimatePrice += item.priceMinus * row.num
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.orderInfo.orderProducts.splice(index, 1, {
|
|
|
+ ...row,
|
|
|
+ estimatePrice: estimatePrice,
|
|
|
+ serviceAmount: serviceAmount
|
|
|
+ })
|
|
|
+ this.orderInfo.serviceAmount = this.orderInfo.orderProducts
|
|
|
+ .map(item => item.serviceAmount || 0)
|
|
|
+ .reduce((a, b) => a + b, 0)
|
|
|
+ },
|
|
|
+ getVfyKey_hs(index, bool = true) {
|
|
|
+ return [
|
|
|
+ ...(() => {
|
|
|
+ if (bool) {
|
|
|
+ return [`orderProducts`]
|
|
|
+ }
|
|
|
+ return []
|
|
|
+ })(),
|
|
|
+ ...(() => {
|
|
|
+ if (index > -1) {
|
|
|
+ return [
|
|
|
+ `orderProducts.${index}.mainId`,
|
|
|
+ `orderProducts.${index}.productId`,
|
|
|
+ `orderProducts.${index}.num`,
|
|
|
+ `orderProducts.${index}.remark`
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ return []
|
|
|
+ })()
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ eidtProduct_hs(row, index) {
|
|
|
+ try {
|
|
|
+ this.orderInfo.orderProducts.map((item, index_) => {
|
|
|
+ if (
|
|
|
+ `${row.bigId}_${row.mainId}_${row.productId}` == `${item.bigId}_${item.mainId}_${item.productId}` &&
|
|
|
+ index_ != index
|
|
|
+ ) {
|
|
|
+ throw new Error('')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.warning('产品机型重复')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.appointVerify(this.getVfyKey_hs(this.isEditIndex_hs), v => {
|
|
|
+ if (v) {
|
|
|
+ if (this.id) {
|
|
|
+ ;[orderBaseProductAdd, orderBaseProductUpdate][row.id ? 1 : 0](row).then(res => {
|
|
|
+ this.isEditIndex_hs = -1
|
|
|
+ this.getOrderBaseProduct()
|
|
|
+ this.getOrderBaseLogList()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.isEditIndex_hs = -1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ delProduct_hs(row, index) {
|
|
|
+ this.appointVerify(this.getVfyKey_hs(this.isEditIndex_hs), v => {
|
|
|
+ if (v && this.id && row.id) {
|
|
|
+ orderBaseProductDelete({
|
|
|
+ orderProductId: row.id
|
|
|
+ }).then(res => {
|
|
|
+ this.getOrderBaseProduct()
|
|
|
+ this.getOrderBaseLogList()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.orderInfo.orderProducts.splice(index, 1)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|