123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757 |
- <template>
- <basic-container>
- <avue-crud :option="option"
- :table-loading="loading"
- :data="data"
- :page.sync="page"
- :permission="permissionList"
- :before-open="beforeOpen"
- :upload-error="uploadError"
- :upload-after="uploadAfter"
- v-model="form"
- ref="crud"
- @row-update="rowUpdate"
- @row-click="handleRowClick"
- @row-save="rowSave"
- @row-del="rowDel"
- @search-change="searchChange"
- @search-reset="searchReset"
- @selection-change="selectionChange"
- @current-change="currentChange"
- @size-change="sizeChange"
- @refresh-change="refreshChange"
- @on-load="onLoad">
- <template slot="isSale" slot-scope="scope" >
- <el-tag v-if="scope.row.$isSale === '上架'" type="success">{{scope.row.$isSale}}</el-tag>
- <el-tag v-if="scope.row.$isSale === '下架'" type="danger">{{scope.row.$isSale}}</el-tag>
- </template>
- <template slot="auditStatus" slot-scope="scope" >
- <el-tag v-if="scope.row.auditStatus === 0">{{scope.row.$auditStatus}}</el-tag>
- <el-tag v-else-if="scope.row.auditStatus === 1" type="success">{{scope.row.$auditStatus}}</el-tag>
- <el-tag v-else-if="scope.row.auditStatus === 2"type="danger">{{scope.row.$auditStatus}}</el-tag>
- </template>
- <template slot-scope="scope" slot="menu">
- <el-button v-if="scope.row.isSale == 1"
- type="text"
- size="small"
- @click="modifyGoodsState(scope.row.id, 0)"
- >下架</el-button>
- <el-button v-if="scope.row.isSale == 0"
- type="text"
- size="small"
- @click="modifyGoodsState(scope.row.id, 1)"
- >上架
- </el-button>
- <el-button
- type="text"
- size="small"
- @click="copyGoods(scope.row.id)"
- >复制</el-button>
- </template>
- </avue-crud>
- <el-dialog title="商品审核" @close="refreshChange"
- append-to-body
- :visible.sync="auditBox"
- :before-close="handleClose"
- width="600px"
- heigh="40%">
- <el-form :model="auditForm" label-width="80px">
- <el-form-item label="审核意见:">
- <el-select v-model="auditForm.auditStatus" placeholder="请选择">
- <el-option
- v-for="item in auditList"
- :key="item.value"
- :label="item.name"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="驳回描述:" v-if="auditForm.auditStatus == 2">
- <el-input type="textarea" v-model="auditForm.remark" :autosize="{ minRows: 3, maxRows: 5}"></el-input>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="handleClose">取 消</el-button>
- <el-button type="primary" @click="auditGoods()">确 定</el-button>
- </div>
- </el-dialog>
- </basic-container>
- </template>
- <script>
- import {getList, getDetail, add, update, remove, modifyState, audit, copy} from "@/api/mall/storegoodsinfo";
- import {mapGetters} from "vuex";
- import {getByParentId} from "../../../api/mall/categoryinfo";
- export default {
- data() {
- var validatePass = (rule, value, callback) => {
- if (value>=10 || value <=0) {
- callback(new Error('非法的折扣'));
- } else {
- callback();
- }
- }
- return {
- option: {
- height: 'auto',
- calcHeight: 30,
- border: true,
- index: false,
- viewBtn: true,
- delBtn:false,
- editBtn: true,
- // selection: true,
- dialogClickModal: false,
- labelWidth: 150,
- searchIcon: true,
- searchIndex: 3,
- column: [
- {
- label: "商品编号",
- search: true,
- prop: "goodsNo",
- overHidden: true,
- addDisplay: false,
- editDisplay: false,
- editDisabled: true,
- width: 160
- },
- {
- label: "缩略图",
- width: 80,
- prop: "goodsCover",
- addDisplay: false,
- viewDisplay: false,
- editDisplay: false,
- type: 'img',
- },
- {
- label: "商品名称",
- prop: "goodsName",
- search: true,
- width: 280,
- overHidden: true,
- rules: [{
- required: true,
- message: "请输入商品名称",
- trigger: "blur"
- }]
- },
- {
- label: "规格",
- prop: "goodsSpec",
- rules: [{
- required: true,
- message: "请输入规格",
- trigger: "blur"
- }]
- },
- {
- label: "品牌",
- prop: "brandDesc",
- hide: true,
- addDisplay: false,
- viewDisplay: false,
- editDisplay: false,
- },
- {
- label: "分类",
- prop: "categoryIdArr",
- hide: true,
- search: true,
- lazy: true,
- rules: [{
- required: true,
- message: "请选择分类",
- trigger: "blur"
- }],
- type: "cascader",
- filterable: true,
- checkStrictly: true,
- lazyLoad(node, resolve) {
- let parentId;
- let stop_level = 2;
- let level = node.level;
- let list = [];
- if (node.level === 0) {
- parentId = 0;
- getByParentId(0).then((res) => {
- list = res.data.data;
- list = (list || []).map(ele => {
- return Object.assign(ele, {
- leaf: level >= stop_level
- })
- })
- resolve(list)
- })
- } else {
- parentId = node.data.id;
- getByParentId(node.data.id).then((res) => {
- list = res.data.data;
- list = (list || []).map(ele => {
- return Object.assign(ele, {
- leaf: level >= stop_level
- })
- })
- resolve(list)
- })
- }
- },
- props: {
- label: "title",
- value: "key"
- },
- },
- {
- label: "品牌",
- prop: "brandId",
- hide: true,
- search: true,
- type: "select",
- remote: true,
- dicUrl: "/api/mall/brandsinfo/getByName?brandName={{key}}",
- props: {
- label: "brandName",
- value: "id"
- },
- dataType: "string",
- },
- // {
- // label: "折扣",
- // prop: "discount",
- // hide: true,
- // precision: 2,
- // type: "number",
- // rules: [{
- // required: true,
- // message: "请输入折扣",
- // trigger: "blur"
- // },{ validator: validatePass, trigger: 'blur' }],
- // },
- {
- label: "供货价",
- prop: "costPrice",
- precision: 2,
- type: "number",
- formatter:(val,value)=>{
- return Number(value).toFixed(2);
- },
- rules: [{
- required: true,
- message: "请输入供货价",
- trigger: "blur"
- }],
- },
- {
- label: "划线价",
- prop: "salePrice",
- precision: 2,
- type: "number",
- formatter:(val,value)=>{
- return Number(value).toFixed(2);
- },
- rules: [{
- required: true,
- message: "请输入划线价",
- trigger: "blur"
- }],
- },
- {
- label: "状态",
- prop: "isSale",
- search: true,
- slot:true,
- rules: [{
- required: true,
- message: "请输入是否上架",
- trigger: "blur"
- }],
- type: "select",
- dicUrl: "/api/blade-system/dict-biz/getEnumDict?enumName=GoodsStateEnum",
- props: {
- label: "name",
- value: "value"
- },
- dataType: "number",
- },
- {
- label: "上架时间",
- prop: "saleTime",
- hide: true,
- addDisplay: false,
- viewDisplay: false,
- editDisplay: false,
- editDisabled: true,
- },
- {
- label: "总库存",
- prop: "totalStock",
- type: "number",
- hide: true,
- min: 1,
- rules: [
- {required: true, message: "请输入总库存", trigger: "blur"},
- ]
- },
- {
- label: "总销量",
- prop: "totalSales",
- hide: true,
- addDisplay: false,
- editDisplay: false,
- },
- {
- label: "总浏览量",
- prop: "totalViews",
- hide: true,
- addDisplay: false,
- editDisplay: false,
- },
- {
- label: "单位",
- prop: "unit",
- hide: true,
- rules: [{
- required: true,
- message: "请选择单位",
- trigger: "blur"
- }],
- type: "select",
- remote: true,
- dicUrl: "/api/mall/unit/all-list",
- props: {
- label: "name",
- value: "id"
- },
- dataType: "string",
- },
- {
- label: "产地",
- prop: "origin",
- hide: true,
- },
- {
- label: "创建时间",
- prop: "createTime",
- hide: true,
- addDisplay: false,
- editDisplay: false,
- editDisabled: false,
- },
- {
- label: '商品缩略图',
- prop: 'uploadCover',
- type: 'upload',
- listType: 'picture-img',
- loadText: '上传中,请稍等',
- accept: 'image/png, image/jpeg',
- fileSize: 500,
- tip: '只能上传jpg/png文件,且不超过500kb',
- span: 24,
- hide: true,
- propsHttp: {
- res: 'data',
- url: 'link',
- },
- action: "/api/blade-resource/oss/endpoint/put-file-attach"
- },
- {
- label: '商品主图',
- prop: 'slideshowList',
- type: 'upload',
- dataType: 'array',
- listType: 'picture-card',
- loadText: '上传中,请稍等',
- accept: 'image/png, image/jpeg',
- fileSize: 1024,
- tip: '只能上传jpg/png文件,且不超过1M',
- span: 24,
- hide: true,
- propsHttp: {
- res: 'data',
- url: 'link',
- },
- action: "/api/blade-resource/oss/endpoint/put-file-attach"
- },
- // {
- // label: '图文详情',
- // prop: 'detailImgUrlList',
- // type: 'upload',
- // dataType: 'array',
- // listType: 'picture-card',
- // loadText: '上传中,请稍等',
- // accept: 'image/png, image/jpeg',
- // fileSize: 2048,
- // tip: '只能上传jpg/png文件,且不超过2M',
- // limit: 25,
- // span: 24,
- // hide: true,
- // propsHttp: {
- // res: 'data',
- // url: 'link',
- // },
- // action: "/api/blade-resource/oss/endpoint/put-file-attach"
- // },
- {
- label: "图文详情",
- prop: "detailContent",
- hide: true,
- span: 24,
- component: 'AvueUeditor',
- options: {
- action: '/api/blade-resource/oss/endpoint/put-file',
- props: {
- res: "data",
- url: "link",
- }
- },
- },
- ]
- },
- range: {
- from: '',
- to: ''
- },
- categoryData: [],
- props: {
- label: "title",
- value: "key"
- },
- categoryIdArr: [],
- auditBox: false,
- auditForm: {
- auditStatus: '',
- id: '',
- remark: ''
- },
- form: {
- },
- goodsParamForm: {},
- goodsSpecForm: {},
- scForm: {},
- query: {},
- goodsParamQuery: {},
- viewSpecQuery: {},
- loading: true,
- paramLoading: true,
- box: false,
- page: {
- pageSize: 10,
- currentPage: 1,
- total: 0
- },
- data: [],
- goodsParamData: [],
- viewSpecData: [],
- scData: [],
- viewDialog: false,
- auditList: [
- {name: '通过', value: 1},{name: '驳回', value: 2}
- ]
- };
- },
- computed: {
- ...mapGetters(["permission"]),
- permissionList() {
- return {
- // addBtn: this.vaildData(this.permission.goodsinfo_add, false),
- // viewBtn: this.vaildData(this.permission.goodsinfo_view, false),
- // delBtn: this.vaildData(this.permission.goodsinfo_delete, false),
- // editBtn: this.vaildData(this.permission.goodsinfo_edit, false)
- };
- },
- ids() {
- let ids = [];
- this.selectionList.forEach(ele => {
- ids.push(ele.id);
- });
- return ids.join(",");
- },
- specIds() {
- let ids = [];
- this.specSelectionList.forEach(ele => {
- ids.push(ele.id);
- });
- return ids.join(",");
- }
- },
- methods: {
- viewDialogShow(row) {
- this.viewDialog = true;
- this.demoModelSrc = `${this.demoModelSrcYuan}?aa=${JSON.stringify(row)}`
- },
- rowSave(row, done, loading) {
- row.goodsCategoryId = row.categoryIdArr.join("-");
- if (row.promotionRateRange == '') {
- delete row.promotionRateRange;
- }
- add(row).then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- done();
- }, error => {
- loading();
- window.console.log(error);
- });
- },
- rowUpdate(row, index, done, loading) {
- row.goodsCategoryId = row.categoryIdArr.join("-") + "-";
- if (row.promotionRateRange == '') {
- delete row.promotionRateRange;
- }
- update(row).then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- done();
- }, error => {
- loading();
- console.log(error);
- });
- },
- rowDel(row) {
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- return remove(row.id);
- })
- .then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- });
- },
- handleDelete() {
- if (this.selectionList.length === 0) {
- this.$message.warning("请选择至少一条数据");
- return;
- }
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- return remove(this.ids);
- })
- .then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.$refs.crud.toggleSelection();
- });
- },
- beforeOpen(done, type) {
- if (["edit", "view"].includes(type)) {
- getDetail(this.form.id).then(res => {
- this.form = res.data.data;
- this.form.uploadCover = res.data.data.goodsCover;
- this.form.goodsVideo = res.data.data.videoUrl;
- this.form.slideshowList = res.data.data.slideshowList;
- this.form.detailImgUrlList = res.data.data.detailImgUrlList;
- this.form.categoryIdArr = this.form.goodsCategoryId.split("-");
- });
- console.log(this.form.goodsCategoryId.split("-"));
- }
- done();
- },
- searchReset() {
- this.query = {};
- this.range = {
- from: '',
- to: ''
- };
- this.activityDate = '';
- this.onLoad(this.page);
- },
- searchChange(params, done) {
- this.query = params;
- this.page.currentPage = 1;
- this.onLoad(this.page, params);
- done();
- },
- selectionChange(list) {
- this.selectionList = list;
- },
- selectionClear() {
- this.selectionList = [];
- this.$refs.crud.toggleSelection();
- },
- currentChange(currentPage){
- this.page.currentPage = currentPage;
- },
- sizeChange(pageSize){
- this.page.pageSize = pageSize;
- },
- refreshChange() {
- this.onLoad(this.page, this.query);
- },
- onLoad(page, params = {}) {
- this.loading = true;
- if (this.query.categoryIdArr) {
- this.query.goodsCategoryId = this.query.categoryIdArr.join("-");
- this.query.categoryIdArr = null;
- }
- this.query.activityDate = this.activityDate;
- getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
- const data = res.data.data;
- this.page.total = data.total;
- this.data = data.records;
- this.loading = false;
- this.selectionClear();
- });
- },
- uploadError(error, column) {
- this.$message.success('上传失败:' + error)
- console.log(error, column)
- },
- uploadAfter(res, done, loading,column) {
- console.log(res,column)
- if(column.prop == "uploadCover") {
- this.form.goodsCover = res.link;
- }
- if (column.prop == "goodsVideo") {
- this.form.videoUrl = res.link;
- }
- done()
- },
- paramConfig(row) {
- this.box = true;
- this.goodsParamQuery.goodsId = row.id;
- this.onLoadParam();
- },
- handleRowClick(row, event, column, loading) {
- if (event.label == '是否上架') {
- const param = {id:row.id, isSale:row.saleSwitch ? 1 : 0}
- update(param).then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: row.saleSwitch ? "上架成功" : "下架成功"
- });
- }, error => {
- loading();
- console.log(error);
- });
- }
- },
- handleClose() {
- this.categoryIdArr = [];
- this.auditBox = false;
- this.auditForm = {
- auditStatus: '',
- id: '',
- remark: ''
- };
- },
- modifyGoodsStateBatch(state) {
- if (this.selectionList.length === 0) {
- this.$message.warning("请选择至少一条数据");
- return;
- }
- this.$confirm("确定修改数据?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- const loading = this.$loading({
- lock: true,
- text: '修改中,请稍等...',
- spinner: 'el-icon-loading',
- background: 'rgba(0, 0, 0, 0.7)'
- });
- modifyState(this.ids, state).then(() => {
- loading.close();
- this.onLoad(this.page, this.query);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.selectionClear()
- });
- })
- },
- modifyGoodsState(id, state) {
- let title = state === 0 ? '确定下架?' : '确定上架?';
- this.$confirm(title, {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- const loading = this.$loading({
- lock: true,
- text: '修改中,请稍等...',
- spinner: 'el-icon-loading',
- background: 'rgba(0, 0, 0, 0.7)'
- });
- modifyState(id, state).then(() => {
- loading.close();
- this.onLoad(this.page, this.query);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.selectionClear()
- });
- })
- },
- openAuditBox(id) {
- this.auditBox = true;
- this.auditForm.id = id;
- },
- auditGoods() {
- audit(this.auditForm).then(() => {
- this.auditBox = false;
- this.onLoad(this.page, this.query);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- }, error => {
- loading();
- console.log(error);
- });
- },
- copyGoods(goodsId) {
- copy(goodsId).then(res => {
- this.$message({
- type: "success",
- message: "复制成功"
- });
- this.onLoad(this.page);
- })
- }
- }
- };
- </script>
- <style>
- </style>
|