From 0411e9f7b2cc909bcdd0b8ef07f11fae804e3f1e Mon Sep 17 00:00:00 2001
From: Mr.Zhang <710666463@qq.com>
Date: 星期五, 15 九月 2023 18:39:17 +0800
Subject: [PATCH] 平台端
---
platform/src/components/business/selectProduct.vue | 119 ++++
platform/src/components/business/OperaGoodsWindow.vue | 672 +++++++++++++-------------
platform/src/components/business/selectProductItem.vue | 183 +++++++
platform/src/views/business/goods.vue | 496 +++++++++----------
4 files changed, 888 insertions(+), 582 deletions(-)
diff --git a/platform/src/components/business/OperaGoodsWindow.vue b/platform/src/components/business/OperaGoodsWindow.vue
index e22ce7f..440f444 100644
--- a/platform/src/components/business/OperaGoodsWindow.vue
+++ b/platform/src/components/business/OperaGoodsWindow.vue
@@ -1,340 +1,350 @@
<template>
- <GlobalWindow
- :title="title"
- :visible.sync="visible"
- :confirm-working="isWorking"
- @confirm="confirm"
- >
- <el-form :model="form" ref="form" :rules="rules">
- <div style="font-size: 18px;font-weight: bold;">鍩烘湰淇℃伅</div>
- <el-form-item label="鍟嗗搧鍚嶇О" prop="name">
- <el-input v-model="form.name" maxlength="50" placeholder="璇疯緭鍏ュ晢鍝佸悕绉帮紝涓嶈秴杩�50涓瓧" v-trim/>
- </el-form-item>
- <el-form-item label="鍟嗗搧鍝佺墝" prop="brandId">
- <el-select v-model="form.brandId" placeholder="璇烽�夋嫨锛屽崟閫�">
- <el-option
- v-for="item in brandList"
- :key="item.id"
- :label="item.name"
- :value="item.id">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="鍟嗗搧绫诲埆" prop="categoryId">
- <!-- @change="changeCategory(form.categoryId)" -->
- <el-select v-model="form.categoryId" placeholder="璇烽�夋嫨锛屽崟閫�">
- <el-option
- v-for="item in categoryList"
- :key="item.id"
- :label="item.name"
- :value="item.id">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item :label="name1" prop="attrFirstIds" v-if="name1">
- <el-select v-model="form.attrFirstIds" multiple placeholder="璇烽�夋嫨锛屾敮鎸佸閫�">
- <el-option
- v-for="item in form.attrFirstList"
- :key="item.id"
- :label="item.name"
- :value="item.id">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item :label="name2" prop="attrSecodIds" v-if="name2">
- <el-select v-model="form.attrSecodIds" multiple placeholder="璇烽�夋嫨锛屾敮鎸佸閫�">
- <el-option
- v-for="item in form.attrSecodList"
- :key="item.id"
- :label="item.name"
- :value="item.id">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="鎸囧浠凤紙鍏冿級" prop="zdPrice">
- <el-input v-model="form.zdPrice" @input="priceCHANEG(form.zdPrice, 1)" type="number" placeholder="寤鸿褰曞叆鏁存暟锛屽崟浣嶅厓" v-trim/>
- </el-form-item>
- <el-form-item label="鍏ユ墜浠凤紙鍏冿級" prop="price">
- <el-input v-model="form.price" @input="priceCHANEG(form.price, 2)" type="number" placeholder="寤鸿褰曞叆鏁存暟锛屽崟浣嶅厓" v-trim/>
- </el-form-item>
- <el-form-item label="鍟嗗搧涓诲浘">
- <el-upload
- :action="action"
- :file-list="form.ztList"
- :data="{ folder: 'projects' }"
- list-type="picture-card"
- :limit="1"
- :on-success="fileSuccess"
- :on-exceed="exceed"
- :on-remove="handleRemove">
- <i class="el-icon-plus"></i>
- <div slot="tip" class="el-upload__tip">鍙兘涓婁紶鍥剧墖鏍煎紡锛宲ng鏍煎紡锛屽缓璁昂瀵�140*140px</div>
- </el-upload>
- </el-form-item>
- <el-form-item label="鍟嗗搧鍥剧墖">
- <el-upload
- :action="action"
- :file-list="form.files"
- :multiple="true"
- :data="{ folder: 'projects' }"
- list-type="picture-card"
- :on-success="fileSuccess1"
- :on-remove="handleRemove1">
- <i class="el-icon-plus"></i>
- <div slot="tip" class="el-upload__tip">鍙兘涓婁紶鍥剧墖鏍煎紡锛宲ng鏍煎紡锛屽缓璁昂瀵�600*600px</div>
- </el-upload>
- </el-form-item>
+ <GlobalWindow
+ :title="title"
+ :visible.sync="visible"
+ :confirm-working="isWorking"
+ @confirm="confirm"
+ width="800px"
+ >
+ <el-form :model="form" ref="form" label-width="120px" :rules="rules">
+ <div style="font-size: 18px;font-weight: bold;">鍩烘湰淇℃伅</div>
+ <el-form-item label="鍟嗗搧鍚嶇О" prop="name">
+ <el-input v-model="form.name" maxlength="50" placeholder="璇疯緭鍏ュ晢鍝佸悕绉帮紝涓嶈秴杩�50涓瓧" v-trim/>
+ </el-form-item>
+ <el-form-item label="鍟嗗搧鍝佺墝" prop="brandId">
+ <el-select v-model="form.brandId" placeholder="璇烽�夋嫨锛屽崟閫�">
+ <el-option
+ v-for="item in brandList"
+ :key="item.id"
+ :label="item.name"
+ :value="item.id">
+ </el-option>
+ </el-select>
+ </el-form-item>
+ <el-form-item label="鍟嗗搧绫诲埆" prop="categoryId">
+ <!-- @change="changeCategory(form.categoryId)" -->
+ <el-select v-model="form.categoryId" placeholder="璇烽�夋嫨锛屽崟閫�">
+ <el-option
+ v-for="item in categoryList"
+ :key="item.id"
+ :label="item.name"
+ :value="item.id">
+ </el-option>
+ </el-select>
+ </el-form-item>
+ <!-- <el-form-item :label="name1" prop="attrFirstIds" v-if="name1">
+ <el-select v-model="form.attrFirstIds" multiple placeholder="璇烽�夋嫨锛屾敮鎸佸閫�">
+ <el-option
+ v-for="item in form.attrFirstList"
+ :key="item.id"
+ :label="item.name"
+ :value="item.id">
+ </el-option>
+ </el-select>
+ </el-form-item>
+ <el-form-item :label="name2" prop="attrSecodIds" v-if="name2">
+ <el-select v-model="form.attrSecodIds" multiple placeholder="璇烽�夋嫨锛屾敮鎸佸閫�">
+ <el-option
+ v-for="item in form.attrSecodList"
+ :key="item.id"
+ :label="item.name"
+ :value="item.id">
+ </el-option>
+ </el-select>
+ </el-form-item> -->
+ <el-form-item label="鎸囧浠凤紙鍏冿級" prop="zdPrice">
+ <el-input v-model="form.zdPrice" @input="priceCHANEG(form.zdPrice, 1)" type="number" placeholder="寤鸿褰曞叆鏁存暟锛屽崟浣嶅厓" v-trim/>
+ </el-form-item>
+ <el-form-item label="鍏ユ墜浠凤紙鍏冿級" prop="price">
+ <el-input v-model="form.price" @input="priceCHANEG(form.price, 2)" type="number" placeholder="寤鸿褰曞叆鏁存暟锛屽崟浣嶅厓" v-trim/>
+ </el-form-item>
+ <el-form-item label="鍟嗗搧涓诲浘">
+ <el-upload
+ :action="action"
+ :file-list="form.ztList"
+ :data="{ folder: 'goods_img' }"
+ list-type="picture-card"
+ :limit="1"
+ :on-success="fileSuccess"
+ :on-exceed="exceed"
+ :on-remove="handleRemove">
+ <i class="el-icon-plus"></i>
+ <div slot="tip" class="el-upload__tip">鍙兘涓婁紶鍥剧墖鏍煎紡锛宲ng鏍煎紡锛屽缓璁昂瀵�140*140px</div>
+ </el-upload>
+ </el-form-item>
+ <el-form-item label="鍟嗗搧鍥剧墖">
+ <el-upload
+ :action="action"
+ :file-list="form.files"
+ :multiple="true"
+ :data="{ folder: 'goods_img' }"
+ list-type="picture-card"
+ :on-success="fileSuccess1"
+ :on-remove="handleRemove1">
+ <i class="el-icon-plus"></i>
+ <div slot="tip" class="el-upload__tip">鍙兘涓婁紶鍥剧墖鏍煎紡锛宲ng鏍煎紡锛屽缓璁昂瀵�600*600px</div>
+ </el-upload>
+ </el-form-item>
+ <template v-if="form.goodsParamList && form.goodsParamList.length > 0">
<div style="font-size: 18px;font-weight: bold;">鍙傛暟灞炴�у�奸厤缃� <span style="font-size: 13px; font-weight: 500;">鎸夐渶閰嶇疆褰撳墠鍟嗗搧鐨勪骇鍝佸弬鏁板�硷紝鍗曚釜鍙傛暟鍊间笉瓒呰繃30涓瓧</span></div>
<el-form-item :label="item.name" v-for="(item, index) in form.goodsParamList" :key="index">
<el-input v-model="item.val" maxlength="30" type="text" placeholder="璇疯緭鍏�" v-trim/>
</el-form-item>
- </el-form>
- </GlobalWindow>
- </template>
-
- <script>
- import BaseOpera from '@/components/base/BaseOpera'
- import GlobalWindow from '@/components/common/GlobalWindow'
- import { brand } from '@/api/system/common.js'
- import { findListForGoodsId, create, updateById } from '@/api/business/goods.js'
- export default {
- name: 'OperaGoodsWindow',
- extends: BaseOpera,
- components: { GlobalWindow },
- data () {
- return {
- action: process.env.VUE_APP_API_PREFIX + '/public/uploadLocal',
- name1: '',
- name2: '',
- // 琛ㄥ崟鏁版嵁
- form: {
- id: null,
- name: '',
- categoryId: '',
- brandId: '',
- zdPrice: '',
- price: '',
- attrFirstIds: [],
- attrFirstNames: '',
- attrSecodIds: [],
- attrSecodNames: '',
- imgurl: '',
- multifileList: [],
- files: [],
- ztList: [],
- goodsParamList: [],
- attrFirstList: [],
- attrSecodList: []
- },
- // 楠岃瘉瑙勫垯
- rules: {
- name: [
- { required: true, message: '涓嶈兘涓虹┖', trigger: 'blur' }
- ],
- categoryId: [
- { required: true, message: '璇烽�夋嫨', trigger: 'change' }
- ],
- brandId: [
- { required: true, message: '璇烽�夋嫨', trigger: 'change' }
- ],
- zdPrice: [
- { required: true, message: '涓嶈兘涓虹┖', trigger: 'blur' }
- ],
- price: [
- { required: true, message: '涓嶈兘涓虹┖', trigger: 'blur' }
- ]
- },
- options: [],
- categoryList: [],
- brandList: []
- }
- },
- created () {
- this.config({
- api: '/business/goods',
- 'field.id': 'id'
- })
- this.getbrand()
- this.getcategory()
- },
- watch: {
- 'form.categoryId': {
- immediate: true,
- handler(news, old) {
- if (news) {
- this.name1 = ''
- this.name2 = ''
- if (old) {
- this.form.attrFirstIds = []
- this.form.attrSecodIds = []
- this.form.goodsParamList = []
- }
- this.categoryList.forEach(item => {
- if (item.id === news) {
- this.name1 = item.attrFirst
- this.name2 = item.attrSecond
- this.form.attrFirstList = item.attrFirstList.length > 0 ? item.attrFirstList : []
- this.form.attrSecodList = item.attrSecondList.length > 0 ? item.attrSecondList : []
- this.form.goodsParamList = JSON.parse(JSON.stringify(item.paramList))
- this.form.goodsParamList.forEach(item => {
- item.pramaId = item.id
- })
- console.log(this.form.goodsParamList)
- }
- })
- this.getcategory(1)
- }
- }
+ </template>
+ </el-form>
+ </GlobalWindow>
+</template>
+
+<script>
+import BaseOpera from '@/components/base/BaseOpera'
+import GlobalWindow from '@/components/common/GlobalWindow'
+import { brand } from '@/api/system/common.js'
+import { findListForGoodsId, create, updateById, companyCreate, companyUpdateById } from '@/api/business/goods.js'
+export default {
+ name: 'OperaGoodsWindow',
+ extends: BaseOpera,
+ components: { GlobalWindow },
+ data () {
+ return {
+ action: process.env.VUE_APP_API_PREFIX + '/public/upload',
+ name1: '',
+ name2: '',
+ // 琛ㄥ崟鏁版嵁
+ form: {
+ id: null,
+ name: '',
+ categoryId: '',
+ brandId: '',
+ zdPrice: '',
+ price: '',
+ attrFirstIds: [],
+ attrFirstNames: '',
+ attrSecodIds: [],
+ attrSecodNames: '',
+ imgurl: '',
+ multifileList: [],
+ files: [],
+ ztList: [],
+ goodsParamList: [],
+ attrFirstList: [],
+ attrSecodList: []
},
- visible: {
- handler(news, old) {
- if (!news) {
- this.name1 = ''
- this.name2 = ''
- this.form = {
- id: null,
- name: '',
- categoryId: '',
- brandId: '',
- zdPrice: '',
- price: '',
- attrFirstIds: [],
- attrFirstNames: '',
- attrSecodIds: [],
- attrSecodNames: '',
- imgurl: '',
- multifileList: [],
- files: [],
- ztList: [],
- goodsParamList: [],
- attrFirstList: [],
- attrSecodList: []
- }
- }
- }
- }
- },
- methods: {
- priceCHANEG(val, type) {
- if (!/^[1-9]+[0-9]*$/.test(val)) {
- this.$message.warning('鍙兘杈撳叆姝f暣鏁�')
- if (type === 1) {
- this.form.zdPrice = ''
- } else {
- this.form.price = ''
- }
- }
+ // 楠岃瘉瑙勫垯
+ rules: {
+ name: [
+ { required: true, message: '涓嶈兘涓虹┖', trigger: 'blur' }
+ ],
+ categoryId: [
+ { required: true, message: '璇烽�夋嫨', trigger: 'change' }
+ ],
+ brandId: [
+ { required: true, message: '璇烽�夋嫨', trigger: 'change' }
+ ],
+ zdPrice: [
+ { required: true, message: '涓嶈兘涓虹┖', trigger: 'blur' }
+ ],
+ price: [
+ { required: true, message: '涓嶈兘涓虹┖', trigger: 'blur' }
+ ]
},
- confirm() {
- this.$refs.form.validate((valid) => {
- if (valid) {
- if (this.form.attrFirstIds.length > 0) {
- let arr = []
- this.form.attrFirstIds.forEach(element => {
- this.form.attrFirstList.forEach(item => {
- if (element === item.id) {
- arr.push(item.name)
- }
- })
- })
- this.form.attrFirstNames = arr.join(',')
- this.form.attrFirstIds = this.form.attrFirstIds.join(',')
- } else {
- this.form.attrFirstNames = ''
- this.form.attrFirstIds = ''
- }
- if (this.form.attrSecodIds.length > 0) {
- let arr = []
- this.form.attrSecodIds.forEach(element => {
- this.form.attrSecodList.forEach(item => {
- if (element === item.id) {
- arr.push(item.name)
- }
- })
- })
- this.form.attrSecodNames = arr.join(',')
- this.form.attrSecodIds = this.form.attrSecodIds.join(',')
- } else {
- this.form.attrSecodNames = ''
- this.form.attrSecodIds = ''
- }
- if (!this.form.id) {
- create(this.form)
- .then(() => {
- this.visible = false
- this.$tip.apiSuccess('鏂板缓鎴愬姛')
- this.$emit('success')
- })
- .catch(e => {
- this.$tip.apiFailed(e)
- })
- .finally(() => {
- this.isWorking = false
- })
- } else {
- updateById(this.form)
- .then(() => {
- this.visible = false
- this.$tip.apiSuccess('缂栬緫鎴愬姛')
- this.$emit('success')
- })
- .catch(e => {
- this.$tip.apiFailed(e)
- })
- .finally(() => {
- this.isWorking = false
- })
- }
- } else {
- return false;
- }
- });
- },
- exceed() {
- this.$message.warning({
- message: '鍙兘涓婁紶涓�涓浘鏍�'
- })
- },
- fileSuccess1(response, file, fileList) {
- this.form.files = fileList
- this.form.multifileList.push({ fileurl: response.data.imgaddr, name: response.data.imgname, url: response.data.url })
- },
- handleRemove1(file, fileList) {
- this.form.files = fileList
- this.form.multifileList = fileList
- },
- fileSuccess(response) {
- this.form.ztList.push({ imgaddr: response.data.imgaddr, url: response.data.url })
- this.form.imgurl = response.data.imgaddr
- },
- handleRemove() {
- this.form.ztList = []
- this.form.imgurl = ''
- },
- getbrand() {
- brand({})
- .then(res => {
- this.brandList = res
- })
- },
- getcategory(type) {
- findListForGoodsId(this.form.id || '')
- .then(res => {
- this.categoryList = res
- if (type === 1) {
- this.categoryList.forEach(item => {
- if (item.id === this.form.categoryId) {
- this.form.goodsParamList = JSON.parse(JSON.stringify(item.paramList))
- this.form.goodsParamList.forEach(item => {
- item.pramaId = item.id
- })
- console.log(this.form.goodsParamList)
- }
- })
- }
- })
- }
+ options: [],
+ categoryList: [],
+ brandList: []
}
+ },
+ created () {
+ this.config({
+ api: '/business/goods',
+ 'field.id': 'id'
+ })
+ this.getbrand()
+ this.getcategory()
+ },
+ watch: {
+ 'form.categoryId': {
+ immediate: true,
+ handler(news, old) {
+ if (news) {
+ this.name1 = ''
+ this.name2 = ''
+ if (old) {
+ this.form.attrFirstIds = []
+ this.form.attrSecodIds = []
+ this.form.goodsParamList = []
+ }
+ this.categoryList.forEach(item => {
+ if (item.id === news) {
+ this.name1 = item.attrFirst
+ this.name2 = item.attrSecond
+ this.form.attrFirstList = item.attrFirstList.length > 0 ? item.attrFirstList : []
+ this.form.attrSecodList = item.attrSecondList.length > 0 ? item.attrSecondList : []
+ this.form.goodsParamList = JSON.parse(JSON.stringify(item.paramList))
+ this.form.goodsParamList.forEach(item => {
+ item.pramaId = item.id
+ })
+ console.log(this.form.goodsParamList)
+ }
+ })
+ this.getcategory(1)
+ }
+ }
+ },
+ visible: {
+ handler(news, old) {
+ if (!news) {
+ this.name1 = ''
+ this.name2 = ''
+ this.form = {
+ id: null,
+ name: '',
+ categoryId: '',
+ brandId: '',
+ zdPrice: '',
+ price: '',
+ attrFirstIds: [],
+ attrFirstNames: '',
+ attrSecodIds: [],
+ attrSecodNames: '',
+ imgurl: '',
+ multifileList: [],
+ files: [],
+ ztList: [],
+ goodsParamList: [],
+ attrFirstList: [],
+ attrSecodList: []
+ }
+ }
+ }
+ }
+ },
+ methods: {
+ priceCHANEG(val, type) {
+ if (!/^[1-9]+[0-9]*$/.test(val)) {
+ this.$message.warning('鍙兘杈撳叆姝f暣鏁�')
+ if (type === 1) {
+ this.form.zdPrice = ''
+ } else {
+ this.form.price = ''
+ }
+ }
+ },
+ confirm() {
+ this.$refs.form.validate((valid) => {
+ if (valid) {
+ if (this.form.attrFirstIds.length > 0) {
+ let arr = []
+ this.form.attrFirstIds.forEach(element => {
+ this.form.attrFirstList.forEach(item => {
+ if (element === item.id) {
+ arr.push(item.name)
+ }
+ })
+ })
+ this.form.attrFirstNames = arr.join(',')
+ this.form.attrFirstIds = this.form.attrFirstIds.join(',')
+ } else {
+ this.form.attrFirstNames = ''
+ this.form.attrFirstIds = ''
+ }
+ if (this.form.attrSecodIds.length > 0) {
+ let arr = []
+ this.form.attrSecodIds.forEach(element => {
+ this.form.attrSecodList.forEach(item => {
+ if (element === item.id) {
+ arr.push(item.name)
+ }
+ })
+ })
+ this.form.attrSecodNames = arr.join(',')
+ this.form.attrSecodIds = this.form.attrSecodIds.join(',')
+ } else {
+ this.form.attrSecodNames = ''
+ this.form.attrSecodIds = ''
+ }
+ if (!this.form.id) {
+ companyCreate({...this.form, type: 0})
+ .then(() => {
+ this.visible = false
+ this.$tip.apiSuccess('鏂板缓鎴愬姛')
+ this.$emit('success')
+ })
+ .catch(e => {
+ this.$tip.apiFailed(e)
+ })
+ .finally(() => {
+ this.isWorking = false
+ })
+ } else {
+ companyUpdateById({...this.form, type: 0})
+ .then(() => {
+ this.visible = false
+ this.$tip.apiSuccess('缂栬緫鎴愬姛')
+ this.$emit('success')
+ })
+ .catch(e => {
+ this.$tip.apiFailed(e)
+ })
+ .finally(() => {
+ this.isWorking = false
+ })
+ }
+ } else {
+ return false;
+ }
+ });
+ },
+ exceed() {
+ this.$message.warning({
+ message: '鍙兘涓婁紶涓�涓浘鏍�'
+ })
+ },
+ fileSuccess1(response, file, fileList) {
+ this.form.files = fileList
+ this.form.multifileList.push({ fileurl: response.data.imgaddr, name: response.data.imgname, url: response.data.url })
+ },
+ handleRemove1(file, fileList) {
+ this.form.files = fileList
+ this.form.multifileList = fileList
+ },
+ fileSuccess(response) {
+ this.form.ztList.push({ imgaddr: response.data.imgaddr, url: response.data.url })
+ this.form.imgurl = response.data.imgaddr
+ },
+ handleRemove() {
+ this.form.ztList = []
+ this.form.imgurl = ''
+ },
+ getbrand() {
+ brand({})
+ .then(res => {
+ this.brandList = res
+ })
+ },
+ getcategory(type) {
+ findListForGoodsId(this.form.id || '')
+ .then(res => {
+ this.categoryList = res
+ if (type === 1) {
+ this.categoryList.forEach(item => {
+ if (item.id === this.form.categoryId) {
+ this.form.goodsParamList = JSON.parse(JSON.stringify(item.paramList))
+ this.form.goodsParamList.forEach(item => {
+ item.pramaId = item.id
+ })
+ console.log(this.form.goodsParamList)
+ }
+ })
+ }
+ })
+ }
}
- </script>
-
\ No newline at end of file
+}
+</script>
+
+<style lang="scss" scoped>
+::v-deep .el-form-item__content {
+ .el-input {
+ width: 400px;
+ }
+}
+</style>
diff --git a/platform/src/components/business/selectProduct.vue b/platform/src/components/business/selectProduct.vue
new file mode 100644
index 0000000..8137bca
--- /dev/null
+++ b/platform/src/components/business/selectProduct.vue
@@ -0,0 +1,119 @@
+<template>
+ <GlobalWindow :title="title" :visible.sync="visible" :confirm-working="isWorking" @confirm="confirm">
+ <el-form :model="form" ref="form" :rules="rules">
+ <el-form-item label="鍟嗗搧绫诲埆" prop="categoryId">
+ <el-select v-model="form.categoryId" placeholder="璇烽�夋嫨">
+ <el-option
+ v-for="item in categoryList"
+ :key="item.id"
+ :label="item.name"
+ :value="item.id">
+ </el-option>
+ </el-select>
+ </el-form-item>
+ <el-form-item label="鍟嗗搧鑼冨洿" prop="type">
+ <el-radio-group v-model="form.type">
+ <el-radio :label="0">鍏ㄩ儴</el-radio>
+ <el-radio :label="1">閮ㄥ垎</el-radio>
+ </el-radio-group>
+ </el-form-item>
+ <el-form-item label="鍔犱环绯绘暟" prop="rate">
+ <el-input v-model="form.rate" placeholder="骞冲彴閲囪喘浠�*鍔犱环绯绘暟锛屼綔涓哄弬鑰冨嚭鎵嬩环锛屽缓璁緭鍏ュぇ浜�1鐨勬暟瀛�" v-trim />
+ </el-form-item>
+ </el-form>
+ <!-- 閫夋嫨骞冲彴鍟嗗搧 -->
+ <selectProductItem ref="selectProductItem" @result="result" />
+ </GlobalWindow>
+ </template>
+
+ <script>
+ import BaseOpera from '@/components/base/BaseOpera'
+ import GlobalWindow from '@/components/common/GlobalWindow'
+ import selectProductItem from '@/components/business/selectProductItem'
+ import { baseCategoryList } from '@/api/business/category.js'
+ import { createPlat } from '@/api/business/goods'
+
+ export default {
+ name: 'OperaBrandWindow',
+ extends: BaseOpera,
+ components: { GlobalWindow, selectProductItem },
+ data() {
+ return {
+ categoryList: [],
+ // 琛ㄥ崟鏁版嵁
+ form: {
+ categoryId: '',
+ type: 0,
+ rate: ''
+ },
+ // 楠岃瘉瑙勫垯
+ rules: {
+ categoryId: [
+ { required: true, message: '鍟嗗搧绫诲埆涓嶈兘涓虹┖', trigger: 'blur' }
+ ],
+ type: [
+ { required: true, message: '鍟嗗搧鑼冨洿涓嶈兘涓虹┖', trigger: 'blur' }
+ ],
+ rate: [
+ { required: true, message: '鍔犱环绯绘暟涓嶈兘涓虹┖', trigger: 'blur' }
+ ]
+ }
+ }
+ },
+ created() {
+ this.config({
+ api: '/business/anchor',
+ 'field.id': 'id'
+ })
+ },
+ methods: {
+ result() {
+ // this.$emit('success')
+ this.$emit('result')
+ this.visible = false
+ },
+ confirm() {
+ this.$refs.form.validate((valid) => {
+ if (!valid) return
+ // 鏂板缓
+ if (this.form.type == 0) {
+ this.isWorking = true
+ createPlat({
+ categoryId: this.form.categoryId,
+ rate: this.form.rate,
+ type: this.form.type
+ }).then(res => {
+ this.visible = false
+ this.$tip.apiSuccess('鎿嶄綔鎴愬姛')
+ // this.$emit('success')
+ this.$emit('result')
+ })
+ .catch(e => {
+ this.$tip.apiFailed(e)
+ })
+ .finally(() => {
+ this.isWorking = false
+ })
+ } else {
+ this.$refs.selectProductItem.open('閫夋嫨骞冲彴鍟嗗搧', this.form)
+ }
+ })
+ },
+ /**
+ * 鎵撳紑绐楀彛
+ * @title 绐楀彛鏍囬
+ * @target 缂栬緫鐨勫璞�
+ */
+ open (title, target) {
+ this.title = title
+ this.visible = true
+ // 鑾峰彇鍒嗙被鍒楄〃
+ baseCategoryList({ type: 1 })
+ .then(res => {
+ this.categoryList = res
+ })
+ }
+ }
+ }
+ </script>
+
\ No newline at end of file
diff --git a/platform/src/components/business/selectProductItem.vue b/platform/src/components/business/selectProductItem.vue
new file mode 100644
index 0000000..50edba6
--- /dev/null
+++ b/platform/src/components/business/selectProductItem.vue
@@ -0,0 +1,183 @@
+<template>
+ <GlobalWindow :title="title" width="70%" :visible.sync="visible" :confirm-working="isWorking" @confirm="confirm">
+ <div class="head">
+ <el-form :inline="true" :model="form" class="demo-form-inline">
+ <el-form-item label="鍟嗗搧鍚嶇О" prop="name">
+ <el-input v-model="form.name" placeholder="璇疯緭鍏ュ晢鍝佸悕绉�"></el-input>
+ </el-form-item>
+ <el-form-item label="绫诲埆" prop="categoryId">
+ <el-select v-model="form.categoryId" disabled placeholder="璇烽�夋嫨">
+ <el-option
+ v-for="item in categoryList"
+ :key="item.id"
+ :label="item.name"
+ :value="item.id">
+ </el-option>
+ </el-select>
+ </el-form-item>
+ <el-form-item>
+ <el-button type="primary" @click="getList">鏌ヨ</el-button>
+ </el-form-item>
+ </el-form>
+ </div>
+ <div class="tab">
+ <el-table
+ :data="tableData"
+ stripe
+ border
+ @selection-change="handleSelectionChange">
+ <el-table-column type="selection" width="55"></el-table-column>
+ <el-table-column prop="id" label="鍟嗗搧ID" min-width="100px"></el-table-column>
+ <el-table-column prop="name" label="鍟嗗搧鍚嶇О/鍨嬪彿" show-overflow-tooltip min-width="200px">
+ <template slot-scope="{row}">
+ <div style="display: flex; align-items: center;">
+ <div style="width: 70px; height: 70px; flex-shrink: 0;">
+ <el-image
+ v-if="row.imgurl"
+ style="width: 70px; height: 70px"
+ :src="row.fullImgUrl"
+ fit="cover"></el-image>
+ </div>
+ {{ row.name }}
+ </div>
+ </template>
+ </el-table-column>
+ <el-table-column prop="brandName" label="鍝佺墝" show-overflow-tooltip min-width="100px"></el-table-column>
+ <el-table-column prop="categoryName" label="绫诲埆" show-overflow-tooltip min-width="100px"></el-table-column>
+ <el-table-column prop="zdPrice" label="鎸囧浠凤紙鍏冿級" show-overflow-tooltip min-width="100px"></el-table-column>
+ <el-table-column prop="price" label="閲囪喘浠凤紙鍏冿級" show-overflow-tooltip min-width="100px"></el-table-column>
+ <el-table-column label="鍏ユ墜浠凤紙鍏冿級" show-overflow-tooltip min-width="100px">
+ <template slot-scope="{row}">
+ <el-input v-model="row.purchasePrice" placeholder="璇疯緭鍏�"></el-input>
+ </template>
+ </el-table-column>
+ </el-table>
+ <el-pagination
+ @size-change="handleSizeChange"
+ @current-change="handleCurrentChange"
+ :current-page="page"
+ :page-sizes="[10, 20, 30]"
+ :page-size="pageSize"
+ layout="total, sizes, prev, pager, next, jumper"
+ :total="total">
+ </el-pagination>
+ </div>
+ </GlobalWindow>
+</template>
+
+<script>
+import BaseOpera from '@/components/base/BaseOpera'
+import GlobalWindow from '@/components/common/GlobalWindow'
+import { baseCategoryList } from '@/api/business/category.js'
+import { pageT } from '@/api/business/goods'
+import { createPlat } from '@/api/business/goods'
+
+export default {
+ name: 'OperaBrandWindow',
+ extends: BaseOpera,
+ components: { GlobalWindow },
+ data() {
+ return {
+ // 琛ㄥ崟鏁版嵁
+ form: {
+ categoryId: '',
+ type: 0,
+ rate: '',
+ name: '',
+ goodsParamList: []
+ },
+ pageSize: 10,
+ page: 1,
+ total: 0,
+ tableData: [],
+ categoryList: []
+ }
+ },
+ created() {
+ this.config({
+ api: '/business/anchor',
+ 'field.id': 'id'
+ })
+ },
+ methods: {
+ getList() {
+ pageT({
+ capacity: this.pageSize,
+ model: {
+ categoryId: this.form.categoryId,
+ name: this.form.name
+ },
+ page: this.page
+ }).then(res => {
+ res.records.forEach(item => {
+ item.purchasePrice = item.price * this.form.rate
+ })
+ this.tableData = res.records
+ this.total = res.total
+ })
+ },
+ handleCurrentChange(e) {
+ this.page = e
+ this.getList()
+ },
+ handleSizeChange(e) {
+ this.pageSize = e
+ this.getList()
+ },
+ handleSelectionChange(e) {
+ let arr = []
+ e.forEach(item => {
+ arr.push({ goodsId: item.id, price: item.purchasePrice })
+ })
+ this.form.goodsParamList = arr
+ console.log(arr)
+ },
+ confirm() {
+ // 璋冪敤鏂板缓鎺ュ彛
+ this.isWorking = true
+ createPlat({
+ categoryId: this.form.categoryId,
+ goodsParamList: this.form.goodsParamList,
+ rate: this.form.rate,
+ type: this.form.type
+ }).then(res => {
+ this.visible = false
+ this.$tip.apiSuccess('鎿嶄綔鎴愬姛')
+ // this.$emit('success')
+ this.$emit('result')
+ })
+ .catch(e => {
+ this.$tip.apiFailed(e)
+ })
+ .finally(() => {
+ this.isWorking = false
+ })
+ },
+ /**
+ * 鎵撳紑绐楀彛
+ * @title 绐楀彛鏍囬
+ * @target 缂栬緫鐨勫璞�
+ */
+ open(title, target) {
+ this.title = title
+ this.visible = true
+ this.form.categoryId = target.categoryId
+ this.form.rate = Number(target.rate)
+ this.form.type = target.type
+ // 鑾峰彇鍒嗙被鍒楄〃
+ baseCategoryList({})
+ .then(res => {
+ this.categoryList = res
+ })
+ this.getList()
+ }
+ }
+}
+</script>
+
+<style lang="scss" scoped>
+ .head {
+ width: 100%;
+
+ }
+</style>
\ No newline at end of file
diff --git a/platform/src/views/business/goods.vue b/platform/src/views/business/goods.vue
index 16d2c4f..c7e81df 100644
--- a/platform/src/views/business/goods.vue
+++ b/platform/src/views/business/goods.vue
@@ -1,260 +1,254 @@
<template>
- <TableLayout :permissions="['business:goods:query']">
- <!-- 鎼滅储琛ㄥ崟 -->
- <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
- <el-form-item label="鍟嗗搧鍚嶇О" prop="name">
- <el-input v-model="searchForm.name" placeholder="璇疯緭鍏ュ晢鍝佸悕绉�" @keypress.enter.native="search"></el-input>
- </el-form-item>
- <el-form-item label="鍟嗗搧ID" prop="id">
- <el-input v-model="searchForm.id" placeholder="璇疯緭鍏ュ晢鍝両D" @keypress.enter.native="search"></el-input>
- </el-form-item>
- <el-form-item label="绫诲埆" prop="categoryId">
- <el-select v-model="searchForm.categoryId" clearable placeholder="璇烽�夋嫨">
- <el-option
- v-for="item in categoryList"
- :key="item.id"
- :label="item.name"
- :value="item.id">
- </el-option>
- </el-select>
- <!-- <el-input v-model="searchForm.categoryId" placeholder="璇疯緭鍏ユ墍灞炲搧绫荤紪鐮�" @keypress.enter.native="search"></el-input> -->
- </el-form-item>
- <el-form-item label="鍝佺墝" prop="brandId">
- <el-select v-model="searchForm.brandId" clearable placeholder="璇烽�夋嫨">
- <el-option
- v-for="item in brandList"
- :key="item.id"
- :label="item.name"
- :value="item.id">
- </el-option>
- </el-select>
- <!-- <el-input v-model="searchForm.brandId" placeholder="璇疯緭鍏ユ墍灞炲搧鐗岀紪鐮�" @keypress.enter.native="search"></el-input> -->
- </el-form-item>
- <el-form-item label="鐘舵��" prop="status">
- <el-select v-model="searchForm.status" clearable placeholder="璇烽�夋嫨">
- <el-option
- v-for="item in statusList"
- :key="item.id"
- :label="item.name"
- :value="item.id">
- </el-option>
- </el-select>
- <!-- <el-input v-model="searchForm.status" placeholder="璇疯緭鍏ョ姸鎬� 0鍚敤 1绂佺敤" @keypress.enter.native="search"></el-input> -->
- </el-form-item>
- <section>
- <el-button type="primary" @click="search">鎼滅储</el-button>
-
- <el-button @click="reset">閲嶇疆</el-button>
- </section>
- </el-form>
- <!-- 琛ㄦ牸鍜屽垎椤� -->
- <template v-slot:table-wrap>
- <ul class="toolbar" v-permissions="['business:goods:create', 'business:goods:delete']">
- <li><el-button type="primary" @click="$refs.operaGoodsWindow.open('鏂板缓鍟嗗搧')" icon="el-icon-plus" v-permissions="['business:goods:create']">鏂板缓</el-button></li>
- <el-button type="primary" :loading="isWorking.export" v-permissions="['business:goods:exportExcel']" @click="importFile">瀵煎叆</el-button>
- <el-button type="primary" :loading="isWorking.export" @click="downloadFile">涓嬭浇妯℃澘</el-button>
- <!-- <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:goods:delete']">鍒犻櫎</el-button></li> -->
- </ul>
- <el-table
- v-loading="isWorking.search"
- :data="tableData.list"
- stripe
- border
- :header-cell-style="rowStyle"
- :cell-style="rowStyle"
- >
- <el-table-column prop="id" label="鍟嗗搧ID" min-width="100px"></el-table-column>
- <el-table-column prop="name" label="鍟嗗搧鍚嶇О/鍨嬪彿" min-width="200px">
- <template slot-scope="{row}">
- <div style="display: flex; align-items: center;">
- <div style="width: 70px; height: 70px; flex-shrink: 0;">
- <el-image
- v-if="row.imgurl"
- style="width: 70px; height: 70px"
- :src="row.prefixUrl + row.imgurl"
- :preview-src-list="[row.prefixUrl + row.imgurl]"
- fit="cover"></el-image>
- </div>
- {{ row.name }}
+ <TableLayout :permissions="['business:goods:query']">
+ <!-- 鎼滅储琛ㄥ崟 -->
+ <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
+ <el-form-item label="鍟嗗搧鍚嶇О" prop="name">
+ <el-input v-model="searchForm.name" placeholder="璇疯緭鍏ュ晢鍝佸悕绉�" @keypress.enter.native="search"></el-input>
+ </el-form-item>
+ <el-form-item label="鍟嗗搧ID" prop="id">
+ <el-input v-model="searchForm.id" placeholder="璇疯緭鍏ュ晢鍝両D" @keypress.enter.native="search"></el-input>
+ </el-form-item>
+ <el-form-item label="绫诲埆" prop="categoryId">
+ <el-select v-model="searchForm.categoryId" clearable placeholder="璇烽�夋嫨">
+ <el-option v-for="item in categoryList" :key="item.id" :label="item.name" :value="item.id">
+ </el-option>
+ </el-select>
+ <!-- <el-input v-model="searchForm.categoryId" placeholder="璇疯緭鍏ユ墍灞炲搧绫荤紪鐮�" @keypress.enter.native="search"></el-input> -->
+ </el-form-item>
+ <el-form-item label="鍝佺墝" prop="brandId">
+ <el-select v-model="searchForm.brandId" clearable placeholder="璇烽�夋嫨">
+ <el-option v-for="item in brandList" :key="item.id" :label="item.name" :value="item.id">
+ </el-option>
+ </el-select>
+ <!-- <el-input v-model="searchForm.brandId" placeholder="璇疯緭鍏ユ墍灞炲搧鐗岀紪鐮�" @keypress.enter.native="search"></el-input> -->
+ </el-form-item>
+ <el-form-item label="鐘舵��" prop="status">
+ <el-select v-model="searchForm.status" clearable placeholder="璇烽�夋嫨">
+ <el-option v-for="item in statusList" :key="item.id" :label="item.name" :value="item.id">
+ </el-option>
+ </el-select>
+ <!-- <el-input v-model="searchForm.status" placeholder="璇疯緭鍏ョ姸鎬� 0鍚敤 1绂佺敤" @keypress.enter.native="search"></el-input> -->
+ </el-form-item>
+ <section>
+ <el-button type="primary" @click="search">鎼滅储</el-button>
+ <el-button @click="reset">閲嶇疆</el-button>
+ </section>
+ </el-form>
+ <!-- 琛ㄦ牸鍜屽垎椤� -->
+ <template v-slot:table-wrap>
+ <ul class="toolbar" v-permissions="['business:goods:create', 'business:goods:delete']">
+ <li><el-button type="primary" @click="$refs.operaGoodsWindow.open('鏂板缓鍟嗗搧')" icon="el-icon-plus"
+ v-permissions="['business:goods:create']">鏂板缓</el-button></li>
+ <!-- <el-button type="primary" :loading="isWorking.export"
+ @click="$refs.selectProduct.open('閫夋嫨骞冲彴鍟嗗搧')">閫夋嫨骞冲彴鍟嗗搧</el-button> -->
+ <el-button type="primary" :loading="isWorking.export" v-permissions="['business:goods:exportExcel']"
+ @click="importFile">瀵煎叆</el-button>
+ <el-button type="primary" :loading="isWorking.export" @click="downloadFile">涓嬭浇妯℃澘</el-button>
+
+ <el-button type="primary" :loading="isWorking.export" @click="bulkOperation(0)">鎵归噺涓婃灦</el-button>
+ <el-button type="primary" :loading="isWorking.export" @click="bulkOperation(1)">鎵归噺涓嬫灦</el-button>
+ <!-- <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:goods:delete']">鍒犻櫎</el-button></li> -->
+ </ul>
+ <el-table v-loading="isWorking.search" :data="tableData.list" stripe border :header-cell-style="rowStyle"
+ :cell-style="rowStyle" @selection-change="handleSelectionChange">
+ <el-table-column type="selection" width="55"></el-table-column>
+ <el-table-column prop="id" label="鍟嗗搧ID" min-width="100px"></el-table-column>
+ <el-table-column prop="name" label="鍟嗗搧鍚嶇О/鍨嬪彿" min-width="200px">
+ <template slot-scope="{row}">
+ <div style="display: flex; align-items: center;">
+ <div style="width: 70px; height: 70px; flex-shrink: 0;">
+ <el-image v-if="row.imgurl" style="width: 70px; height: 70px" :src="row.prefixUrl + row.imgurl"
+ :preview-src-list="[row.prefixUrl + row.imgurl]" fit="cover"></el-image>
</div>
- </template>
- </el-table-column>
- <el-table-column prop="brandName" label="鍝佺墝" min-width="100px"></el-table-column>
- <el-table-column prop="categoryName" label="绫诲埆" min-width="100px"></el-table-column>
- <el-table-column prop="attrFirstNames" label="灞炴��1" min-width="100px"></el-table-column>
- <el-table-column prop="attrSecodNames" label="灞炴��2" min-width="100px"></el-table-column>
- <el-table-column prop="zdPrice" label="鎸囧浠凤紙鍏冿級" min-width="100px"></el-table-column>
- <el-table-column prop="price" label="鍏ユ墜浠凤紙鍏冿級" min-width="100px"></el-table-column>
- <el-table-column prop="createDate" label="鍒涘缓鏃堕棿" min-width="100px"></el-table-column>
- <el-table-column prop="status" label="鐘舵��" min-width="100px">
- <template slot-scope="{row}">
- <el-switch
- v-model="row.status"
- @change="changeStatus(row)"
- active-color="#13ce66"
- inactive-color="#ff4949"
- :active-value="0"
- :inactive-value="1">
- </el-switch>
- </template>
- </el-table-column>
- <el-table-column
- v-if="containPermissions(['business:goods:update', 'business:goods:delete'])"
- label="鎿嶄綔"
- min-width="120"
- fixed="right"
- >
- <template slot-scope="{row}">
- <el-button type="text" @click="edit(row.id)" icon="el-icon-edit" v-permissions="['business:goods:update']">缂栬緫</el-button>
- <el-button type="text" @click="deleteById(row)" icon="el-icon-delete" v-permissions="['business:goods:delete']">鍒犻櫎</el-button>
- </template>
- </el-table-column>
- </el-table>
- <input type="file" ref="upload" style="display: none;" @change="uplaodFile" />
- <pagination
- @size-change="handleSizeChange"
- @current-change="handlePageChange"
- :pagination="tableData.pagination"
- >
- </pagination>
- </template>
- <!-- 鏂板缓/淇敼 -->
- <OperaGoodsWindow ref="operaGoodsWindow" @success="handlePageChange"/>
- </TableLayout>
- </template>
-
- <script>
- import BaseTable from '@/components/base/BaseTable'
- import TableLayout from '@/layouts/TableLayout'
- import Pagination from '@/components/common/Pagination'
- import OperaGoodsWindow from '@/components/business/OperaGoodsWindow'
- import { brand, category, importExcel } from '@/api/system/common.js'
- import { updateDisableById, queryById, exportDoc } from '@/api/business/goods.js'
- export default {
- name: 'Goods',
- extends: BaseTable,
- components: { TableLayout, Pagination, OperaGoodsWindow },
- data () {
- return {
- // 鎼滅储
- searchForm: {
- id: '',
- name: '',
- status: '',
- categoryId: '',
- brandId: ''
- },
- categoryList: [],
- brandList: [],
- statusList: [
- { name: '鍚敤', id: 0 },
- { name: '绂佺敤', id: 1 }
- ]
+ {{ row.name }}
+ </div>
+ </template>
+ </el-table-column>
+ <el-table-column prop="brandName" label="鍝佺墝" min-width="100px"></el-table-column>
+ <el-table-column prop="categoryName" label="绫诲埆" min-width="100px"></el-table-column>
+ <el-table-column prop="baseZdPrice" label="鎸囧浠凤紙鍏冿級" min-width="100px"></el-table-column>
+ <el-table-column prop="basePrice" label="閲囪喘浠�(鍏�)" min-width="100px"></el-table-column>
+ <el-table-column prop="price" label="鍏ユ墜浠凤紙鍏冿級" min-width="100px"></el-table-column>
+ <el-table-column prop="createDate" label="鍒涘缓鏃堕棿" min-width="100px"></el-table-column>
+ <el-table-column prop="status" label="鐘舵��" min-width="100px">
+ <template slot-scope="{row}">
+ <el-switch v-model="row.status" @change="changeStatus(row)" active-color="#13ce66" inactive-color="#ff4949"
+ :active-value="0" :inactive-value="1">
+ </el-switch>
+ </template>
+ </el-table-column>
+ <el-table-column v-if="containPermissions(['business:goods:update', 'business:goods:delete'])" label="鎿嶄綔"
+ min-width="120" fixed="right">
+ <template slot-scope="{row}">
+ <el-button type="text" @click="edit(row.id)" icon="el-icon-edit"
+ v-permissions="['business:goods:update']">缂栬緫</el-button>
+ <el-button type="text" @click="deleteById(row)" icon="el-icon-delete"
+ v-permissions="['business:goods:delete']">鍒犻櫎</el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ <input type="file" ref="upload" style="display: none;" @change="uplaodFile" />
+ <pagination @size-change="handleSizeChange" @current-change="handlePageChange" :pagination="tableData.pagination">
+ </pagination>
+ </template>
+ <!-- 鏂板缓/淇敼 -->
+ <OperaGoodsWindow ref="operaGoodsWindow" @success="handlePageChange" />
+ <!-- 閫夋嫨骞冲彴鍟嗗搧 -->
+ <selectProduct ref="selectProduct" @success="handlePageChange" @result="search" />
+ </TableLayout>
+</template>
+
+<script>
+import BaseTable from '@/components/base/BaseTable'
+import TableLayout from '@/layouts/TableLayout'
+import Pagination from '@/components/common/Pagination'
+import OperaGoodsWindow from '@/components/business/OperaGoodsWindow'
+import selectProduct from '@/components/business/selectProduct'
+import { brand, category, importExcel } from '@/api/system/common.js'
+import { updateDisableById, queryById, exportDoc, batchUpdateDisableById } from '@/api/business/goods.js'
+export default {
+ name: 'Goods',
+ extends: BaseTable,
+ components: { TableLayout, Pagination, OperaGoodsWindow, selectProduct },
+ data() {
+ return {
+ // 鎼滅储
+ searchForm: {
+ id: '',
+ name: '',
+ status: '',
+ categoryId: '',
+ brandId: ''
+ },
+ ids: '',
+ categoryList: [],
+ brandList: [],
+ statusList: [
+ { name: '鍚敤', id: 0 },
+ { name: '绂佺敤', id: 1 }
+ ]
+ }
+ },
+ created() {
+ this.config({
+ module: '鍟嗗搧',
+ api: '/business/goods',
+ 'field.id': 'id',
+ 'field.main': 'name'
+ })
+ this.search()
+ this.getbrand()
+ this.getcategory()
+ },
+ methods: {
+ handleSelectionChange(e) {
+ let arr = e.map(item => item.id)
+ this.ids = arr.join(',')
+ console.log(this.ids)
+ },
+ // 鎵归噺涓婁笅鏋�
+ bulkOperation(type) {
+ if (!this.ids) {
+ this.$message.warning({ message: '鑷冲皯閫夋嫨涓�椤瑰唴瀹�' })
+ return
}
- },
- created () {
- this.config({
- module: '鍟嗗搧',
- api: '/business/goods',
- 'field.id': 'id',
- 'field.main': 'name'
+ batchUpdateDisableById({
+ ids: this.ids,
+ status: type
+ }).then(res => {
+ this.$message.success({ message: res })
+ this.search()
})
- this.search()
- this.getbrand()
- this.getcategory()
},
- methods: {
- downloadFile() {
- // window.open(`${process.env.VUE_APP_API_PREFIX}/business/goods/export`)
- exportDoc({})
- .then(response => {
- this.download(response)
- })
- .catch(e => {
- this.$tip.apiFailed(e)
- })
- },
- rowStyle() {
- return "text-align:center";
- },
- importFile() {
- this.$refs.upload.click()
- },
- uplaodFile(e) {
- const FORMDATE = new FormData()
- FORMDATE.append('file', e.target.files[0])
- // 璇锋眰鎺ュ彛
- importExcel(FORMDATE)
- .then(res => {
- console.log(res)
- this.search()
- })
- .catch ((err) => {
- this.$message.error(err.message)
- })
- this.$refs.upload.value = null
- },
- edit(id) {
- queryById(id)
- .then(res => {
- let obj = {
- id: res.id,
- name: res.name,
- categoryId: res.categoryId,
- brandId: res.brandId,
- zdPrice: res.zdPrice,
- price: res.price,
- attrFirstIds: res.attrFirstIds ? this.turnNum(res.attrFirstIds.split(',')) : [],
- attrFirstNames: res.attrFirstNames,
- attrSecodIds: res.attrSecodIds ? this.turnNum(res.attrSecodIds.split(',')) : [],
- attrSecodNames: res.attrSecodNames,
- imgurl: res.imgurl,
- multifileList: [],
- files: [],
- ztList: res.imgurl ? [{ url: res.prefixUrl + res.imgurl }] : [],
- pzList: [],
- attrFirstList: [],
- attrSecodList: []
- }
- if (res.multifileList.length > 0) {
- res.multifileList.forEach(item => {
- obj.multifileList.push({ fileurl: item.fileurl, name: item.name, url: res.prefixUrl + item.fileurl })
- obj.files.push({ fileurl: item.fileurl, name: item.name, url: res.prefixUrl + item.fileurl })
- })
- }
- this.$refs.operaGoodsWindow.open('缂栬緫鍟嗗搧', obj)
- })
- },
- changeStatus(item) {
- updateDisableById({
- id: item.id,
- status: item.status
- }).then(res => {
- this.$tip.apiSuccess('鏇存柊鎴愬姛')
- }).finally(() => {
- // this.search()
+ downloadFile() {
+ exportDoc({})
+ .then(response => {
+ this.download(response)
})
- },
- turnNum (nums) {
- for(let i=0;i<nums.length;i++){
- nums[i] = parseInt(nums[i])
- }
- return nums;
- },
- getbrand() {
- brand({})
- .then(res => {
- this.brandList = res
- })
- },
- getcategory() {
- category({})
- .then(res => {
- this.categoryList = res
- })
- }
+ .catch(e => {
+ this.$tip.apiFailed(e)
+ })
+ },
+ rowStyle() {
+ return "text-align:center";
+ },
+ importFile() {
+ this.$refs.upload.click()
+ },
+ uplaodFile(e) {
+ const FORMDATE = new FormData()
+ FORMDATE.append('file', e.target.files[0])
+ // 璇锋眰鎺ュ彛
+ importExcel(FORMDATE)
+ .then(res => {
+ console.log(res)
+ this.search()
+ })
+ .catch((err) => {
+ this.$message.error(err.message)
+ })
+ this.$refs.upload.value = null
+ },
+ edit(id) {
+ queryById(id)
+ .then(res => {
+ let obj = {
+ id: res.id,
+ name: res.name,
+ categoryId: res.categoryId,
+ brandId: res.brandId,
+ zdPrice: res.zdPrice,
+ price: res.price,
+ attrFirstIds: res.attrFirstIds ? this.turnNum(res.attrFirstIds.split(',')) : [],
+ attrFirstNames: res.attrFirstNames,
+ attrSecodIds: res.attrSecodIds ? this.turnNum(res.attrSecodIds.split(',')) : [],
+ attrSecodNames: res.attrSecodNames,
+ imgurl: res.imgurl,
+ multifileList: [],
+ files: [],
+ ztList: res.imgurl ? [{ url: res.prefixUrl + res.imgurl }] : [],
+ pzList: [],
+ attrFirstList: [],
+ attrSecodList: []
+ }
+ if (res.multifileList.length > 0) {
+ res.multifileList.forEach(item => {
+ obj.multifileList.push({ fileurl: item.fileurl, name: item.name, url: res.prefixUrl + item.fileurl })
+ obj.files.push({ fileurl: item.fileurl, name: item.name, url: res.prefixUrl + item.fileurl })
+ })
+ }
+ this.$refs.operaGoodsWindow.open('缂栬緫鍟嗗搧', obj)
+ })
+ },
+ changeStatus(item) {
+ updateDisableById({
+ id: item.id,
+ status: item.status
+ }).then(res => {
+ this.$tip.apiSuccess('鏇存柊鎴愬姛')
+ }).finally(() => {
+ // this.search()
+ })
+ },
+ turnNum(nums) {
+ for (let i = 0; i < nums.length; i++) {
+ nums[i] = parseInt(nums[i])
+ }
+ return nums;
+ },
+ getbrand() {
+ brand({})
+ .then(res => {
+ this.brandList = res
+ })
+ },
+ getcategory() {
+ category({})
+ .then(res => {
+ this.categoryList = res
+ })
}
}
- </script>
-
\ No newline at end of file
+}
+</script>
--
Gitblit v1.9.3