diff --git a/src/components/Modal/GoodsModal/GoodsModal.vue b/src/components/Modal/GoodsModal/GoodsModal.vue index 59ee4be..2044fae 100644 --- a/src/components/Modal/GoodsModal/GoodsModal.vue +++ b/src/components/Modal/GoodsModal/GoodsModal.vue @@ -47,7 +47,7 @@ image: item.goods_image, imageAlt: '商品图片', title: item.goods_name, - subtitle: `¥${item.goods_price_min}` + subtitle: `¥${item.goods_price_min}`, }" :subTitleColor="true" /> @@ -71,27 +71,27 @@ import { STable, GoodsItem } from '@/components/Table' const columns = [ { title: '商品ID', - dataIndex: 'goods_id' + dataIndex: 'goods_id', }, { title: '商品信息', width: '335px', - scopedSlots: { customRender: 'item' } + scopedSlots: { customRender: 'item' }, }, { title: '商品价格', dataIndex: 'goods_price_min', - scopedSlots: { customRender: 'goods_price_min' } + scopedSlots: { customRender: 'goods_price_min' }, }, { title: '库存总量', - dataIndex: 'stock_total' + dataIndex: 'stock_total', }, { title: '状态', dataIndex: 'status', - scopedSlots: { customRender: 'status' } - } + scopedSlots: { customRender: 'status' }, + }, ] export default { @@ -102,13 +102,13 @@ export default { // 最大选择的数量限制, multiple模式下有效 maxNum: PropTypes.integer.def(100), // 默认选中的列表记录 - defaultList: PropTypes.array.def([]) + defaultList: PropTypes.array.def([]), }, components: { STable, - GoodsItem + GoodsItem, }, - data () { + data() { return { // 对话框标题 title: '商品库', @@ -119,15 +119,17 @@ export default { // 当前表单元素 searchForm: this.$form.createForm(this), // 查询参数 - queryParam: {}, + queryParam: { + channel: 'zy', + status: 10, + }, // table表头 columns, // 加载数据方法 必须为 Promise 对象 - loadData: param => { - return GoodsApi.list({ ...param, ...this.queryParam }) - .then(response => { - return response.data.list - }) + loadData: (param) => { + return GoodsApi.list({ ...param, ...this.queryParam }).then((response) => { + return response.data.list + }) }, // 主键ID字段名 fieldName: 'goods_id', @@ -136,26 +138,25 @@ export default { // 已选择的列表记录 selectedItems: [], // 商品分类列表 - categoryListTree: [] + categoryListTree: [], } }, computed: { - rowSelection () { + rowSelection() { return { selectedRowKeys: this.selectedRowKeys, onChange: this.onSelectChange, - type: !this.multiple ? 'radio' : 'checkbox' + type: !this.multiple ? 'radio' : 'checkbox', } - } + }, }, - created () { + created() { // 获取商品分类列表 this.getCategoryList() }, methods: { - // 显示对话框 - handle () { + handle() { // 显示窗口 this.visible = true this.$nextTick(() => { @@ -167,24 +168,24 @@ export default { }, // 设置默认数据 - setDefaultValue () { + setDefaultValue() { const { fieldName, defaultList } = this if (defaultList.length) { this.selectedItems = cloneDeep(defaultList) - this.selectedRowKeys = defaultList.map(item => item[fieldName]) + this.selectedRowKeys = defaultList.map((item) => item[fieldName]) } }, // 获取分类列表 - getCategoryList () { + getCategoryList() { this.isLoading = true CategoryModel.getListFromScreen() - .then(selectList => this.categoryListTree = selectList) - .finally(() => this.isLoading = false) + .then((selectList) => (this.categoryListTree = selectList)) + .finally(() => (this.isLoading = false)) }, // 选中项发生变化时的回调 - onSelectChange (selectedRowKeys, newSelectedItems) { + onSelectChange(selectedRowKeys, newSelectedItems) { const { selectedItems } = this this.selectedRowKeys = selectedRowKeys this.selectedItems = this.createSelectedItems(selectedRowKeys, selectedItems, newSelectedItems) @@ -196,16 +197,16 @@ export default { * @param array oldSelectedItems 已选择的列表记录 (change前) * @param array newSelectedItems 已选择的列表记录 (change后) */ - createSelectedItems (selectedRowKeys, oldSelectedItems, newSelectedItems) { + createSelectedItems(selectedRowKeys, oldSelectedItems, newSelectedItems) { const { fieldName } = this const selectedItems = [] - oldSelectedItems.forEach(item => { + oldSelectedItems.forEach((item) => { if (selectedRowKeys.includes(item[fieldName])) { selectedItems.push(item) } }) - const oldSelectedKeys = oldSelectedItems.map(item => item[fieldName]) - newSelectedItems.forEach(item => { + const oldSelectedKeys = oldSelectedItems.map((item) => item[fieldName]) + newSelectedItems.forEach((item) => { if (!oldSelectedKeys.includes(item[fieldName]) && selectedRowKeys.includes(item[fieldName])) { selectedItems.push(item) } @@ -217,12 +218,12 @@ export default { * 刷新列表 * @param Boolean bool 强制刷新到第一页 */ - handleRefresh (bool = false) { + handleRefresh(bool = false) { this.$refs.table.refresh(true) }, // 确认搜索 - handleSearch (e) { + handleSearch(e) { e.preventDefault() this.searchForm.validateFields((error, values) => { if (!error) { @@ -233,7 +234,7 @@ export default { }, // 关闭对话框事件 - handleCancel () { + handleCancel() { this.visible = false this.queryParam = {} this.searchForm.resetFields() @@ -242,18 +243,17 @@ export default { }, // 确认按钮 - handleSubmit (e) { + handleSubmit(e) { e.preventDefault() // 通知父端组件提交完成了 this.$emit('handleSubmit', { selectedItems: this.selectedItems, - selectedRowKeys: this.selectedRowKeys + selectedRowKeys: this.selectedRowKeys, }) // 关闭对话框 this.handleCancel() - } - - } + }, + }, } diff --git a/src/views/goods/modules/Update.vue b/src/views/goods/modules/Update.vue index c458adb..5dcb6f7 100644 --- a/src/views/goods/modules/Update.vue +++ b/src/views/goods/modules/Update.vue @@ -639,6 +639,7 @@ export default { // 获取form所需的数据 this.isLoading = true GoodsModel.getFromData(this.goodsId).then(() => { + this.formData.goods.goods_images = [] // 商品表单数据 if (!isEmptyObject(this.form.getFieldsValue())) { // 第一次赋值