123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590 |
- import { listPageV2 } from '@/api/auxiliaryFittings/supplier'
- import { materialCategoryList } from '@/api/auxiliaryMaterialClass'
- import { materialNormList } from '@/api/auxiliaryPriceManagement'
- import { listPageV2 as peijianList } from '@/api/auxiliaryFittings/attachmentProfile'
- import { required, mobileRequired, mobile } from '@/components/template/rules_verify.js'
- import { storageListPageV2 } from '@/api/storage'
- import { getCategory } from '@/api/auxiliaryFittings/auxiliarySalesOrder'
- import { getGoods } from '@/api/auxiliaryFittings/auxiliarySalesOrder'
- export default {
- data() {
- return {
- materialNormList: [],
- peijianList: []
- }
- },
- computed: {
- // 事件组合
- columns() {
- return [
- ...(() => {
- if (this.formData.type == 'M') {
- return [
- {
- columnAttributes: {
- label: '大类名称',
- prop: 'parentCategoryId'
- },
- render: (h, { row, column, index }) => {
- return row.isEditRow ? (
- <div class="redbordererr">
- <el-form-item
- label=""
- lebel-width="0px"
- prop={`items.${index}.parentCategoryId`}
- rules={required}
- >
- <el-select
- disabled={this.formDialogType == 2}
- value={row[column.columnAttributes.prop]}
- onInput={val => {
- row[column.columnAttributes.prop] = val
- }}
- onChange={val => {
- row['goodsCategoryId'] = ''
- row['goodsCategoryName'] = ''
- row['goodsId'] = ''
- row['goodsName'] = ''
- this.materialNormList = []
- this.qkrow(row)
- if (val) {
- row['parentCategoryName'] = this.mainList.find(
- item => item.categoryId == val
- ).categoryName
- } else {
- row['parentCategoryName'] = ''
- }
- this.$nextTick(this.jiaoyan)
- }}
- placeholder="请选择"
- >
- {this.mainList.map((item, index_) => (
- <el-option key={index_} label={item.categoryName} value={item.categoryId}></el-option>
- ))}
- </el-select>
- </el-form-item>
- </div>
- ) : (
- <div>{row['parentCategoryName']}</div>
- )
- }
- }
- ]
- }
- return []
- })(),
- ...(() => {
- if (this.formData.type == 'M') {
- return [
- {
- columnAttributes: {
- label: '小类名称',
- prop: 'goodsCategoryId'
- },
- render: (h, { row, column, index }) => {
- return row.isEditRow ? (
- <div class="redbordererr">
- <el-form-item label="" lebel-width="0px" prop={`items.${index}.goodsCategoryId`} rules={required}>
- <el-select
- disabled={this.formDialogType == 2}
- value={row[column.columnAttributes.prop]}
- onInput={val => {
- row[column.columnAttributes.prop] = val
- }}
- placeholder="请选择"
- onChange={val => {
- row['goodsId'] = ''
- row['goodsName'] = ''
- this.qkrow(row)
- if (val) {
- row['goodsCategoryName'] = (
- this.mainList.find(item => item.categoryId == row.parentCategoryId)?.items || []
- ).find(item => item.categoryId == val).categoryName
- materialNormList({
- isShowStockQty: true,
- websitId: this.formData.websitId,
- storageId: this.formData.storageId,
- pageNum: 1,
- pageSize: -1,
- params: [
- { param: 'b.category_id', compare: '=', value: val },
- { param: 'a.status', compare: '=', value: 'ON' }
- ]
- }).then(res => {
- this.materialNormList = res.data.records
- })
- } else {
- this.materialNormList = []
- row['goodsCategoryName'] = ''
- }
- this.$nextTick(this.jiaoyan)
- }}
- >
- {(this.mainList.find(item => item.categoryId == row.parentCategoryId)?.items || []).map(
- (item, index_) => (
- <el-option key={index_} label={item.categoryName} value={item.categoryId}></el-option>
- )
- )}
- </el-select>
- </el-form-item>
- </div>
- ) : (
- <div>{row['goodsCategoryName']}</div>
- )
- }
- }
- ]
- }
- return []
- })(),
- ...(() => {
- if (this.formData.type == 'M') {
- return [
- {
- columnAttributes: {
- label: '辅材',
- prop: 'goodsId'
- },
- render: (h, { row, column, index }) => {
- return row.isEditRow ? (
- <div class="redbordererr">
- <el-form-item label="" lebel-width="0px" prop={`items.${index}.goodsId`} rules={required}>
- <el-select
- disabled={this.formDialogType == 2}
- value={row[column.columnAttributes.prop]}
- onInput={val => {
- row[column.columnAttributes.prop] = val
- }}
- placeholder="请选择"
- onChange={val => {
- if (val) {
- var data = this.materialNormList.find(item => item.goodsId == val)
- row['goodsName'] = data.goodsName
- this.qkrow(row, {
- goodsStockUnit: data.goodsStockUnit,
- goodsCode: data.goodsCode,
- goodsSpecification: data.goodsSpecification,
- brand: '',
- productCategory: ''
- })
- } else {
- row['goodsName'] = ''
- this.qkrow(row)
- }
- this.$nextTick(this.jiaoyan)
- }}
- >
- {this.materialNormList
- .filter(
- item =>
- !~[
- ...this.formData.items.map(val => val.goodsId).filter(val => val != row.goodsId)
- ].indexOf(item.goodsId)
- )
- .map((item, index_) => (
- <el-option key={index_} label={item.goodsName} value={item.goodsId}></el-option>
- ))}
- </el-select>
- </el-form-item>
- </div>
- ) : (
- <div>{row['goodsName']}</div>
- )
- }
- }
- ]
- }
- return []
- })(),
- ...(() => {
- if (this.formData.type == 'P') {
- return [
- {
- columnAttributes: {
- label: '配件',
- prop: 'goodsId'
- },
- render: (h, { row, column, index }) => {
- return row.isEditRow ? (
- <div class="redbordererr">
- <el-form-item label="" lebel-width="0px" prop={`items.${index}.goodsId`} rules={required}>
- <el-select
- disabled={this.formDialogType == 2}
- value={row[column.columnAttributes.prop]}
- onInput={val => {
- row[column.columnAttributes.prop] = val
- }}
- placeholder="请选择"
- onChange={val => {
- this.materialNormList = []
- if (val) {
- var data = this.peijianList.find(item => item.goodsId == val)
- row['goodsName'] = data.goodsName
- this.qkrow(row, {
- goodsStockUnit: data.goodsStockUnit,
- goodsCode: data.goodsCode,
- goodsSpecification: data.goodsSpecification,
- brand: data.brandRelaName,
- productCategory: data.productRelaName
- })
- } else {
- row['goodsName'] = ''
- this.qkrow(row)
- }
- this.$nextTick(this.jiaoyan)
- }}
- >
- {this.peijianList
- .filter(
- item =>
- !~[
- ...this.formData.items.map(val => val.goodsId).filter(val => val != row.goodsId)
- ].indexOf(item.goodsId)
- )
- .map((item, index_) => (
- <el-option key={index_} label={item.goodsName} value={item.goodsId}></el-option>
- ))}
- </el-select>
- </el-form-item>
- </div>
- ) : (
- <div>{row['goodsName']}</div>
- )
- }
- }
- ]
- }
- return []
- })(),
- {
- columnAttributes: {
- label: '单位',
- prop: 'goodsStockUnit'
- }
- },
- {
- columnAttributes: {
- label: '数量',
- prop: 'qty'
- },
- render: (h, { row, column, index }) => {
- return row.isEditRow ? (
- <div class="redbordererr">
- <el-form-item
- label=""
- lebel-width="0px"
- prop={`items.${index}.${column.columnAttributes.prop}`}
- rules={required}
- >
- <el-input
- disabled={this.formDialogType == 2}
- type="number"
- value={row[column.columnAttributes.prop]}
- onInput={val => {
- row[column.columnAttributes.prop] = val
- }}
- placeholder="请选择"
- ></el-input>
- </el-form-item>
- </div>
- ) : (
- <div>{row[column.columnAttributes.prop]}</div>
- )
- }
- },
- ...(() => {
- if (this.formData.type == 'M') {
- return [
- {
- columnAttributes: {
- label: '商品代码',
- prop: 'goodsCode'
- }
- },
- {
- columnAttributes: {
- label: '规格型号',
- prop: 'goodsSpecification'
- }
- }
- ]
- }
- return []
- })(),
- ...(() => {
- if (this.formData.type == 'P') {
- return [
- {
- columnAttributes: {
- label: '配件编码',
- prop: 'goodsCode'
- }
- },
- {
- columnAttributes: {
- label: '适用品牌',
- prop: 'brand'
- }
- },
- {
- columnAttributes: {
- label: '适用产品大类',
- prop: 'productCategory'
- }
- }
- ]
- }
- return []
- })(),
- ...(() => {
- if (!!~[0, 1].indexOf(this.formDialogType)) {
- return [
- {
- columnAttributes: {
- label: '操作',
- prop: ''
- },
- render: (h, { row, column, index }) => {
- return (
- <div class="operation-btns">
- <el-button
- type="text"
- onClick={() => {
- this.formData.items.splice(index, 1)
- }}
- >
- 删除
- </el-button>
- {row.isEditRow ? (
- <el-button
- type="text"
- onClick={() => {
- this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
- if (valid) {
- this.formData.items.splice(index, 1, {
- ...this.formData.items[index],
- isEditRow: false
- })
- }
- })
- }}
- >
- 确定
- </el-button>
- ) : null}
- {!row.isEditRow ? (
- <el-button
- type="text"
- onClick={() => {
- this.formData.items.map((item, index_) => {
- if (index_ == index) {
- this.formData.items.splice(index, 1, {
- ...this.formData.items[index],
- isEditRow: true
- })
- if (this.formData.type == 'M' && row.goodsCategoryId) {
- materialNormList({
- isShowStockQty: true,
- websitId: this.formData.websitId,
- pageNum: 1,
- pageSize: -1,
- params: [
- { param: 'b.category_id', compare: '=', value: row.goodsCategoryId },
- { param: 'a.status', compare: '=', value: 'ON' }
- ]
- }).then(res => {
- this.materialNormList = res.data.records
- })
- }
- } else {
- this.formData.items.splice(index_, 1, {
- ...this.formData.items[index_],
- isEditRow: false
- })
- }
- })
- }}
- >
- 编辑
- </el-button>
- ) : null}
- </div>
- )
- }
- }
- ]
- }
- return []
- })()
- ]
- },
- formItems2() {
- return [
- {
- md: 24,
- isShow: true,
- name: 'slot-component',
- formItemAttributes: {
- label: '',
- prop: 'items',
- 'label-width': '0px',
- rules: [...required]
- },
- render: (h, { props, onInput }) => {
- var { value } = props
- return (
- <div>
- {!!~[0, 1].indexOf(this.formDialogType) ? (
- <div style="margin-bottom:8px">
- <el-button
- onClick={() => {
- this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
- if (valid || (Object.keys(invalidFields).length == 1 && invalidFields.items)) {
- this.formData.items.map(item => {
- item.isEditRow = false
- })
- this.formData.items.push({
- isEditRow: true,
- brand: '',
- goodsCategoryId: '',
- goodsCategoryName: '',
- goodsCode: '',
- goodsId: '',
- goodsName: '',
- goodsSpecification: '',
- goodsStockUnit: '',
- goodsType: '',
- parentCategoryId: '',
- parentCategoryName: '',
- productCategory: '',
- qty: 0,
- websitGoodsMoveId: '',
- websitId: '',
- websitName: ''
- })
- }
- })
- }}
- >
- 添加
- </el-button>
- </div>
- ) : null}
- <zj-table
- columns={this.columns}
- tableData={this.formData.items}
- tableAttributes={{
- size: 'mini',
- border: true
- }}
- />
- </div>
- )
- }
- }
- ]
- }
- },
- watch: {
- 'formData.websitId'(newVal) {
- this.biyaowebsitId(newVal)
- this.biyaooutwarehouseList()
- },
- 'formData.type'(newVal) {
- this.biyaooutwarehouseList()
- },
- 'formData.outStorageId'(newValue) {
- this.biyaooutStorageId()
- }
- },
- methods: {
- biyaooutwarehouseList() {
- if (this.formData.type && this.formData.websitId) {
- storageListPageV2({
- pageNum: 1,
- pageSize: -1,
- params: [
- { param: 'a.websit_id', compare: '=', value: this.formData.websitId },
- { param: 'a.status', compare: '=', value: 'true' },
- {
- param: 'a.type',
- compare: 'like',
- value: (() => {
- if (this.formData.type == 'M') {
- return '辅材'
- } else if (this.formData.type == 'P') {
- return '配件'
- }
- return ''
- })()
- }
- ]
- }).then(res => {
- this.warehouseList = res.data.records
- })
- } else {
- this.warehouseList = []
- }
- },
- biyaooutStorageId() {
- if (this.formData.outStorageId && this.formData.websitId) {
- getGoods({
- websitId: this.formData.websitId,
- type: 'P',
- saleType: '零售',
- storageId: this.formData.outStorageId
- }).then(res => {
- this.peijianList = res.data
- })
- } else {
- this.peijianList = []
- }
- },
- biyaowebsitId(newVal) {
- if (newVal) {
- getCategory({ websitId: newVal }).then(res => {
- this.mainList = res.data
- })
- if (this.formData.outStorageId && this.formData.websitId) {
- getGoods({
- websitId: this.formData.websitId,
- type: 'P',
- saleType: '零售',
- storageId: this.formData.outStorageId
- }).then(res => {
- this.peijianList = res.data
- })
- }
- } else {
- this.warehouseList = []
- this.mainList = []
- this.peijianList = []
- }
- },
- qkrow(row, data = {}) {
- ;['goodsStockUnit', 'goodsCode', 'goodsSpecification', 'brand', 'productCategory'].map(key => {
- if (row[key] !== undefined) {
- row[key] = data[key] !== undefined ? data[key] : ''
- }
- })
- },
- // 添加
- addData() {
- this.formDialogType = 0
- this.openForm()
- },
- // 关闭弹窗
- formCancel() {
- this.$refs.formRef.$refs.inlineForm.clearValidate()
- this.$data.formData = this.$options.data().formData
- this.formDialog = false
- },
- jiaoyan() {
- this.$refs.formRef.validate((valid, invalidFields, errLabels) => {}, false)
- },
- setNumber(val) {
- return Number(val.toFixed(2))
- }
- }
- }
|