|
@@ -0,0 +1,162 @@
|
|
|
+<template>
|
|
|
+ <div id="goods">
|
|
|
+ <template v-if="view === 'list'">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" style="padding: 10px">
|
|
|
+ <el-button type="primary" size="mini" @click="toBack()">返回</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <data-search :fields="searchFields" v-model="searchInfo" @query="search">
|
|
|
+ <template #status>
|
|
|
+ <el-option v-for="i in goodsStatusList" :key="i.value" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ </data-search>
|
|
|
+ <data-btn :fields="btnList" @add="toAdd"></data-btn>
|
|
|
+ <data-table ref="dataTable" :fields="fields" :opera="opera" :data="list" :total="total" :limit="limit" @query="search"></data-table>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-button type="primary" size="mini" @click="toBackList()">返回</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <data-form :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave">
|
|
|
+ <template #tags="{ item }">
|
|
|
+ <el-cascader v-model="form[item.model]" :options="tagsList" :props="props" clearable filterable :show-all-levels="false"></el-cascader>
|
|
|
+ </template>
|
|
|
+ <template #act_tags>
|
|
|
+ <el-option v-for="i in act_tagsList" :key="i.value" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #status>
|
|
|
+ <el-option v-for="i in goodsStatusList" :key="i.value" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #brief>
|
|
|
+ <editor v-model="form.brief" url="/files/point/goods/upload" />
|
|
|
+ </template>
|
|
|
+ </data-form>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+const _ = require('lodash');
|
|
|
+import methodsUtil from '@/util/opera';
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+export default {
|
|
|
+ name: 'index',
|
|
|
+ props: {},
|
|
|
+ components: { editor: () => import('@/components/editor.vue') },
|
|
|
+ data: function () {
|
|
|
+ return {
|
|
|
+ view: 'list',
|
|
|
+ fields: [
|
|
|
+ { label: '姓名', model: 'name' },
|
|
|
+ { label: '店铺名称', model: 'shop.name' },
|
|
|
+ // { label: '商品分类', model: 'tags', format: (i) => this.getTags(i) },
|
|
|
+ // { label: '活动标签', model: 'act_tags', format: (i) => this.getAct_tags(i) },
|
|
|
+ // { label: '商品状态', model: 'status', format: (i) => this.getStatus(i) },
|
|
|
+ ],
|
|
|
+ opera: [
|
|
|
+ // { label: '修改', method: 'edit' },
|
|
|
+ // { label: '上架', method: 'puton', display: (i) => i.status == '0' },
|
|
|
+ // { label: '下架', method: 'lower', display: (i) => i.status == '1' },
|
|
|
+ // { label: '库存管理', method: 'spec' },
|
|
|
+ // { label: '删除', method: 'delete', confirm: true, type: 'danger' },
|
|
|
+ ],
|
|
|
+ btnList: [{ label: '添加', method: 'add' }],
|
|
|
+ searchFields: [{ label: '名称', model: 'name' }],
|
|
|
+ searchInfo: {},
|
|
|
+ list: [{ name: '222' }],
|
|
|
+ total: 0,
|
|
|
+ limit: 10,
|
|
|
+ // info部分
|
|
|
+ infoFields: [
|
|
|
+ { label: '商品名称', model: 'name' },
|
|
|
+ { label: '商品分类', model: 'tags', custom: true },
|
|
|
+ { label: '活动标签', model: 'act_tags', type: 'selectMany' },
|
|
|
+ { label: '简短简介', model: 'shot_brief', maxLength: 50 },
|
|
|
+ { label: '预计发货时间', model: 'send_time' },
|
|
|
+ { label: '商品状态', model: 'status', type: 'select' },
|
|
|
+ { label: '商品来源', model: 'source' },
|
|
|
+ { label: '网址', model: 'url' },
|
|
|
+ { label: '排序', model: 'sort', type: 'number' },
|
|
|
+ { label: '商品图片', model: 'file', type: 'upload', url: '/files/point/goods/upload' },
|
|
|
+ { label: '商品介绍', model: 'brief', custom: true },
|
|
|
+ ],
|
|
|
+ rules: {},
|
|
|
+ form: {},
|
|
|
+ // 商品分类
|
|
|
+ tagsList: [],
|
|
|
+ props: { multiple: true, label: 'label', value: 'code' },
|
|
|
+ // 活动标签
|
|
|
+ act_tagsList: [],
|
|
|
+ goodsStatusList: [],
|
|
|
+ shop: {},
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.searchOthers();
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...methodsUtil,
|
|
|
+ async search({ skip = 0, limit = this.limit, ...others } = {}) {
|
|
|
+ // let query = { skip, limit, ...others };
|
|
|
+ // if (Object.keys(this.searchInfo).length > 0) query = { ...query, ...this.searchInfo };
|
|
|
+ // const res = await this.getGoods(query);
|
|
|
+ // if (this.$checkRes(res)) {
|
|
|
+ // this.$set(this, `list`, res.data);
|
|
|
+ // this.$set(this, `total`, res.total);
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ initAddData() {
|
|
|
+ const obj = {
|
|
|
+ status: '1',
|
|
|
+ shop: _.get(this.shop, '_id'),
|
|
|
+ };
|
|
|
+ this.$set(this, 'form', obj);
|
|
|
+ },
|
|
|
+ async searchOthers() {},
|
|
|
+ // getStatus(data) {
|
|
|
+ // const res = this.goodsStatusList.find((f) => f.value === data);
|
|
|
+ // if (res) return res.label;
|
|
|
+ // return '';
|
|
|
+ // },
|
|
|
+ // getAct_tags(data) {
|
|
|
+ // const arr = [];
|
|
|
+ // for (const val of data) {
|
|
|
+ // const r = this.act_tagsList.find((f) => f.value === val);
|
|
|
+ // if (r) arr.push(r.label);
|
|
|
+ // }
|
|
|
+ // return arr.join(';');
|
|
|
+ // },
|
|
|
+ // getTags(data) {
|
|
|
+ // let list = this.tagsList;
|
|
|
+ // const getChildren = (list) =>
|
|
|
+ // list.map((i) => {
|
|
|
+ // if (i.children) return getChildren(i.children);
|
|
|
+ // return i;
|
|
|
+ // });
|
|
|
+ // list = _.flattenDeep(getChildren(list));
|
|
|
+ // const arr = [];
|
|
|
+ // for (const ts of data) {
|
|
|
+ // const last = _.last(ts);
|
|
|
+ // const r = list.find((f) => f.code === last);
|
|
|
+ // if (r) arr.push(r.label);
|
|
|
+ // }
|
|
|
+ // return arr.join(';');
|
|
|
+ // },
|
|
|
+ toBack() {
|
|
|
+ window.history.go('-1');
|
|
|
+ },
|
|
|
+ toBackList() {
|
|
|
+ this.view = 'list';
|
|
|
+ this.form = {};
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped></style>
|