|
@@ -0,0 +1,89 @@
|
|
|
|
+<template>
|
|
|
|
+ <div id="goods">
|
|
|
|
+ <template v-if="view === 'list'">
|
|
|
|
+ <csearch :fields="searchFields" v-model="searchInfo" @query="search"></csearch>
|
|
|
|
+ <cbtn :list="btnList" @add="toAdd"></cbtn>
|
|
|
|
+ <ctable ref="ctable" :fields="fields" :opera="opera" :data="list" :total="total" :limit="limit" @query="search"></ctable>
|
|
|
|
+ </template>
|
|
|
|
+ <template v-else>
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="24">
|
|
|
|
+ <el-button icon="el-icon-back" size="mini" @click="toBack()">返回</el-button>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="24">
|
|
|
|
+ <cform :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px"></cform>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ </template>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import csearch from '@/components/usual/c-search.vue';
|
|
|
|
+import cbtn from '@/components/usual/c-btnbar.vue';
|
|
|
|
+import ctable from '@/components/usual/c-table.vue';
|
|
|
|
+import cform from '@/components/usual/c-form.vue';
|
|
|
|
+import methodsUtil from './opera';
|
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
+const { mapActions: selfShop } = createNamespacedHelpers('selfShop');
|
|
|
|
+const { mapActions: goods } = createNamespacedHelpers('goods');
|
|
|
|
+export default {
|
|
|
|
+ name: 'index',
|
|
|
|
+ props: {},
|
|
|
|
+ components: { cbtn, ctable, csearch, cform },
|
|
|
|
+ data: function () {
|
|
|
|
+ return {
|
|
|
|
+ view: 'list',
|
|
|
|
+ fields: [
|
|
|
|
+ { label: '商品名称', model: 'name' },
|
|
|
|
+ { label: '店铺名称', model: 'shop.name' },
|
|
|
|
+ { label: '商品状态', model: 'status_label' },
|
|
|
|
+ ],
|
|
|
|
+ opera: [
|
|
|
|
+ { label: '修改', method: 'edit' },
|
|
|
|
+ { label: '删除', method: 'delete', confirm: true, type: 'danger' },
|
|
|
|
+ ],
|
|
|
|
+ btnList: [{ label: '添加', method: 'add' }],
|
|
|
|
+ searchFields: [
|
|
|
|
+ { label: '商品名称', model: 'name' },
|
|
|
|
+ { label: '商品状态', model: 'status' },
|
|
|
|
+ ],
|
|
|
|
+ searchInfo: {},
|
|
|
|
+ list: [],
|
|
|
|
+ total: 0,
|
|
|
|
+ limit: 10,
|
|
|
|
+ // info部分
|
|
|
|
+ infoFields: [
|
|
|
|
+ { label: '商品名称', model: 'name' },
|
|
|
|
+ { label: '简短简介', model: 'shot_brief', maxLength: 50 },
|
|
|
|
+ { label: '规格', model: 'specs', custom: true },
|
|
|
|
+ { label: '预计发货时间', model: 'send_time' },
|
|
|
|
+ { label: '商品图片', model: 'file', custom: true },
|
|
|
|
+ { label: '商品介绍', model: 'brief' },
|
|
|
|
+ { label: '商品状态', model: 'status', type: 'select' },
|
|
|
|
+ ],
|
|
|
|
+ rules: {},
|
|
|
|
+ form: {},
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ this.search();
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ ...selfShop(['getInfo', 'getGoods', 'goodsCreate']),
|
|
|
|
+ ...goods(['delete', 'fetch', 'update']),
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ ...methodsUtil,
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="less" scoped></style>
|