shish 5 lat temu
rodzic
commit
e09ec66ce1

+ 1 - 1
ghsApp/src/pagesStorehouse/flower/category.vue

@@ -83,7 +83,7 @@ export default {
 					custom: "warn"
 				},
 				{
-					name: "每扎采购价",
+					name: "每扎成本",
 					width: 130,
 					color: "info",
 					align: "center",

+ 233 - 0
hd/src/components/module/item-list-layer.vue

@@ -0,0 +1,233 @@
+<template>
+  <el-dialog
+    title="选择花材"
+    :visible.sync="selDialog"
+    :close-on-click-modal="false"
+    :append-to-body="true"
+    @close="$emit('update:show', false)"
+    width="800px"
+  >
+    <div class="recharge-modal-content">
+      <el-checkbox-group
+        v-model="checkList"
+        class="radio-wrap"
+      >
+        <x-crud
+          class="liu-crud-wrap"
+          @load="onLoad"
+        >
+          <template #table-column-radio="{scope}">
+            <div>
+              <el-checkbox
+                v-if="scope.row.select == 2"
+                disabled
+                :label="scope.row"
+              >{{scope.row.id}}</el-checkbox>
+              <el-checkbox
+                v-else
+                :label="scope.row"
+              >{{scope.row.id}}</el-checkbox>
+            </div>
+          </template>
+
+          <template #table-column-select="{scope}">
+            <span v-if="scope.row.select == 2">✔</span>
+            <span v-else></span>
+          </template>
+
+          <template #table-column-stockWarning="{scope}">
+            <el-input
+              v-model="scope.row.stockWarning"
+              placeholder="最低库存"
+              size="small"
+            ></el-input>
+          </template>
+
+          <template #table-column-cost="{scope}">
+            <el-input
+              v-model="scope.row.cost"
+              placeholder="成本价"
+              size="small"
+            ></el-input>
+          </template>
+
+          <template #table-column-addPrice="{scope}">
+            <el-input
+              v-model="scope.row.addPrice"
+              placeholder="加价"
+              size="small"
+            ></el-input>
+          </template>
+
+          <template #table-column-cover="{scope}">
+            <div>
+              <cl-avatar
+                shape="square"
+                :size="40"
+                :src="scope.row.cover | default_avatar"
+                :style="{ margin: 'auto' }"
+              ></cl-avatar>
+            </div>
+          </template>
+        </x-crud>
+      </el-checkbox-group>
+    </div>
+    <div
+      slot="footer"
+      class="dialog-footer"
+    >
+      <el-button
+        size="small"
+        @click="resetForm"
+      >取 消</el-button>
+      <el-button
+        type="primary"
+        size="small"
+        @click="confirmFn"
+      >确定</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+export default {
+  name: 'sj-list-layer',
+  props: {
+    show: {
+      type: Boolean,
+      default: false
+    },
+    multi: {
+      type: Boolean,
+      default: false
+    }
+  },
+  data () {
+    return {
+      selDialog: false,
+      ruleForm: {},
+      checkList: [],
+      list: [],
+    };
+  },
+  computed: {
+  },
+  watch: {
+    show () {
+      console.log(this.show)
+      this.selDialog = this.show;
+    }
+  },
+  created () { },
+  methods: {
+    confirmFn () {
+      if (this.checkList.length > 0) {
+        this.$emit('confirm', this.checkList);
+      } else {
+        this.$message.warning('请至少选择一项花材');
+      }
+
+    },
+    resetForm () {
+      this.$emit('cancel');
+    },
+    onLoad ({ ctx, app }) {
+      this.app = app;
+
+      let getItemList = () => {
+        return this.$service.ptItem.list();
+      };
+      ctx.service({
+        page: getItemList
+      })
+        .set('table', {
+          columns: [
+            {
+              prop: 'radio',
+              label: '选择',
+              align: 'center',
+              width: 120
+            },
+            {
+              prop: 'cover',
+              label: '图片',
+              align: 'center',
+              width: 130
+            },
+            {
+              prop: 'name',
+              label: '名称',
+              align: 'center'
+            },
+            {
+              prop: 'stockWarning',
+              label: '最低库存提醒',
+              align: 'center'
+            },
+            {
+              prop: 'cost',
+              label: '成本价',
+              align: 'center'
+            },
+            {
+              prop: 'addPrice',
+              label: '加价',
+              align: 'center'
+            },
+            {
+              prop: 'select',
+              label: '已添加',
+              align: 'center'
+            }
+          ],
+          on: {
+            'row-click': (row, column) => {
+              console.log(666666666666666)
+              console.log(row)
+            }
+          },
+          // 操作列
+          op: {
+            visible: false // 是否显示
+          }
+        })
+        .set('dict', {
+          search: {
+            keyWord: 'name'
+          }
+        })
+        .set('search', {
+          key: {
+            placeholder: '花材名称,支持拼音首字母搜索'
+          }
+        })
+        .set('pagination', {
+          size: 6
+        })
+        .set('layout', [
+          ['slot-tabs'],
+          ['search-key', 'flex1', 'refresh-btn'],
+          ['data-table'],
+          ['flex1', 'pagination']
+        ])
+        .on('refresh', async (params, { next, render }) => {
+          // 继续执行刷新
+          let { list } = await next(params);
+          list.map((e, index) => {
+            e.index = index;
+          });
+          this.list = list;
+          render(list);
+        })
+        .done();
+      app.refresh({ type: this.tabIndex });
+    }
+  }
+};
+</script>
+<style lang="scss">
+// 列表
+.radio-wrap {
+  display: block;
+}
+</style>

+ 7 - 2
hd/src/cool/request/index.js

@@ -24,9 +24,11 @@ import sassMember from '@/service/sass/member/index';
 import sassPtMember from '@/service/sass/pt-member/index';
 import sassFest from '@/service/sass/fest/index';
 import sassAuth from '@/service/sass/auth/index';
-
 import shop from '@/service/shop/index';
 import chat from '@/service/chat/index';
+import itemClass from '@/service/item-class/index';
+import item from '@/service/item/index';
+import ptItem from '@/service/pt-item/index';
 
 export function SET_SERVICE({ store }) {
 	// const files = require.context('@/service/', true, /\.js$/);
@@ -58,7 +60,10 @@ export function SET_SERVICE({ store }) {
 		sassFest,
 		sassAuth,
 		shop,
-		chat
+		chat,
+		itemClass,
+		item,
+		ptItem
 	};
 
 	Vue.prototype.$service = modules;

+ 23 - 1
hd/src/mock/userInfo.js

@@ -320,7 +320,7 @@ let menu = {
 			keepAlive: 1
 		},
 		{
-			id: '406',
+			id: '409',
 			parentId: '4',
 			name: '商品说明',
 			type: 1,
@@ -330,6 +330,28 @@ let menu = {
 			viewPath: 'views/goods/summary.vue',
 			keepAlive: 1
 		},
+		{
+			id: '412',
+			parentId: '4',
+			name: '花材分类',
+			type: 1,
+			icon: 'icon-user',
+			orderNum: 4,
+			router: '/item-class/list',
+			viewPath: 'views/item-class/list.vue',
+			keepAlive: 1
+		},
+		{
+			id: '415',
+			parentId: '4',
+			name: '花材列表',
+			type: 1,
+			icon: 'icon-user',
+			orderNum: 4,
+			router: '/item/list',
+			viewPath: 'views/item/list.vue',
+			keepAlive: 1
+		},
 		// 邀请有礼
 		{
 			id: '6',

+ 27 - 0
hd/src/service/item-class/index.js

@@ -0,0 +1,27 @@
+import { BaseService, Service } from '@/cool';
+
+@Service('item-class')
+export class ItemClassService extends BaseService {
+
+	addClass(data) {
+		return this.request({
+			url: '/add',
+			method: 'POST',
+			data: data
+		});
+	}
+	updateClass(data) {
+		return this.request({
+			url: '/update',
+			method: 'POST',
+			data: data
+		});
+	}
+	deleteClass(data) {
+		return this.request({
+			url: '/delete',
+			params: data
+		});
+	}
+}
+export default new ItemClassService();

+ 27 - 0
hd/src/service/item/index.js

@@ -0,0 +1,27 @@
+import { BaseService, Service } from '@/cool';
+
+@Service('item')
+export class ItemService extends BaseService {
+    /**
+	 * 新增花材 b
+	 */
+	itemAdd(data) {
+		return this.request({
+			url: '/add',
+			method: 'POST',
+			data: data
+		});
+  }
+    /**
+	 * 批量新增花材 b
+	 */
+    batchAdd(data) {
+		return this.request({
+			url: '/batch-add',
+			method: 'POST',
+			data: data
+		});
+  }
+  
+}
+export default new ItemService();

+ 7 - 0
hd/src/service/pt-item/index.js

@@ -0,0 +1,7 @@
+import { BaseService, Service } from '@/cool';
+
+@Service('pt-item')
+export class PtItemService extends BaseService {
+
+}
+export default new PtItemService();

+ 0 - 14
hd/src/views/home.vue

@@ -101,20 +101,6 @@
 				</div>
 			</div>
 		</div>
-		<!-- 提示 -->
-		<el-dialog title="提示" :visible.sync="promptModal" width="400px">
-			<div class="prompt-wrap">
-				<div
-					class="prompt-list"
-					v-for="(item, index) in noticeData"
-					:key="index"
-					@click="noticeFn(item)"
-				>
-					<div>{{ item.title }}</div>
-					<div class="prompt-action">{{ item.action }}</div>
-				</div>
-			</div>
-		</el-dialog>
 	</div>
 </template>
 

+ 328 - 0
hd/src/views/item-class/list.vue

@@ -0,0 +1,328 @@
+<template>
+	<div class="app-list-content">
+		<x-crud class="liu-crud-wrap" @load="onLoad">
+			<template #slot-tabs>
+				<el-tabs
+					class="liu-tabs"
+					type="border-card"
+					v-model="tabIndex"
+					@tab-click="handleClick"
+				>
+					<el-tab-pane
+						v-for="(item, index) in tabsData"
+						:key="index"
+						:label="item.text"
+						:name="item.key"
+					>
+					</el-tab-pane>
+				</el-tabs>
+			</template>
+
+			<template #table-column-num="{scope}">
+				<el-link
+					@click="getItemList(scope.row)"
+				>{{ scope.row.num }}</el-link>
+			</template>
+
+			<template #table-column-name="{scope}">
+				<el-link
+					@click="getItemList(scope.row)"
+				>{{ scope.row.name }}</el-link>
+			</template>
+
+			<template #table-column-inTurn="{scope}">
+				<span v-if="!sort.status">{{ scope.row.inTurn }}</span>
+				<el-input
+					ref="sort-input"
+					focus
+					size="mini"
+					v-else
+					v-model="scope.row.inTurn"
+					@blur="changeSort(scope.row)"
+				></el-input>
+			</template>
+
+			<!-- 排序 -->
+			<template #table-header-inTurn>
+				<div class="set-sort">
+					<span>排序</span>
+					<el-button
+						v-if="!sort.status"
+						icon="el-icon-edit-outline"
+						size="small"
+						type="text"
+						@click="showSort"
+						class="show"
+					></el-button>
+
+					<el-button class="hide" v-else size="mini" @click="hideSort" type="primary"
+						>完成</el-button
+					>
+				</div>
+			</template>
+
+			<!-- 添加分类 -->
+			<template #slot-add-goods-btn>
+				<el-button type="primary" size="mini" @click="replaceBtnFn(0)">添加</el-button>
+			</template>
+
+			<template #slot-item-list="{scope}">
+				<el-button type="text" @click.native.stop="getItemList(scope.row)">花材列表</el-button>
+			</template>
+
+			<template #slot-modify="{scope}">
+				<el-button type="text" @click.native.stop="replaceBtnFn(scope.row.id,scope.row.name)">修改</el-button>
+			</template>
+
+		</x-crud>
+
+
+		<!-- 新增弹窗 -->
+		<el-dialog
+			:title="`${id == 0 ? '添加' : '修改'}花材`"
+			:visible.sync="replaceDialog"
+			:close-on-click-modal="false"
+			width="600px"
+		>
+			<div class="ad-modal-content">
+				<el-form :model="replaceForm" :rules="ruleForm" ref="replaceForm" label-width="100px" class="demo-form">
+					<el-form-item label="分类名称" prop="name">
+						<el-input v-model="replaceForm.name" placeholder="请输入名称" size="small"></el-input>
+					</el-form-item>
+				</el-form>
+			</div>
+			<div slot="footer" class="dialog-footer">
+				<el-button size="small" @click="resetForm">取 消</el-button>
+				<el-button type="primary" size="small" @click="submitForm('replaceForm')">确认</el-button>
+			</div>
+		</el-dialog>
+
+
+	</div>
+</template>
+
+<script>
+import { mapGetters } from 'vuex';
+
+export default {
+	data() {
+		return {
+			app: null,
+			sortLink: '',
+			operateData: {},
+			tabIndex: '0',
+			tabsData: [
+				{
+					text: '花材分类',
+					key: '0'
+				}
+			],
+			selects: {},
+			sort: {
+				status: false
+			},
+			replaceDialog:false,
+			id:0,
+			replaceForm: {
+				name: ''
+			},
+			ruleForm: {
+				name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
+			},
+		};
+	},
+	computed: {
+	},
+	methods: {
+		deleteFn(id){
+			let self = this
+			this.$confirm('确认删除?', '提示', {
+				confirmButtonText: '确定',
+				cancelButtonText: '取消',
+				type: 'warning'
+			}).then(() => {
+				this.$service.itemClass.deleteClass({id:id}).then(res => {
+					self.replaceDialog = false
+					self.app.refresh();
+				});
+			});
+		},
+		resetForm(){
+			this.$refs['replaceForm'].resetFields();
+			this.replaceDialog = false
+		},
+		replaceFn() {
+			let replaceForm = JSON.parse(JSON.stringify(this.replaceForm));
+			let self = this
+			if (self.id == 0) {
+				this.$service.itemClass.addClass(replaceForm).then(res => {
+					self.replaceDialog = false
+					self.resetForm();
+					self.app.refresh();
+				});
+			} else {
+				this.$service.itemClass.updateClass({id:self.id,...replaceForm}).then(res => {
+					self.replaceDialog = false
+					self.resetForm();
+					self.app.refresh();
+				});
+			}
+		},
+		submitForm(formName) {
+			this.$refs[formName].validate(valid => {
+				if (valid) {
+					this.replaceFn();
+				} else {
+					console.log('error submit!!');
+					return false;
+				}
+			});
+		},
+		replaceBtnFn(id,name) {
+			this.id = id
+			this.replaceForm.name = name
+			this.replaceDialog = true
+		},
+		handleClick(tab, e) {
+			this.app.refresh({ type: this.tabIndex });
+		},
+		//添加花材
+		getItemList(data) {
+			let query = {};
+			query.classId = data.id
+			query.name = data.name
+			this.$router.push({ path: '/item/list', query });
+		},
+		// x-crud 组件
+		onLoad({ ctx, app }) {
+			this.app = app;
+			ctx.service(this.$service.itemClass)
+				.set('table', {
+					columns: [
+						{
+							prop: 'id',
+							label: 'ID',
+							align: 'center'
+						},
+						{
+							prop: 'name',
+							label: '标题',
+							align: 'center',
+							'min-width': 180
+						},
+						{
+							prop: 'num',
+							label: '花材数量',
+							align: 'center',
+							'min-width': 100
+						},
+						{
+							prop: 'inTurn',
+							label: '排序',
+							align: 'center',
+							minWidth: 100
+						},
+						{
+							prop: 'addTime',
+							label: '创建时间',
+							align: 'center',
+							minWidth: 180
+						}
+					],
+
+					on: {
+						'row-click': (row, column) => {
+							this.getItemList(row)
+						}
+					},
+
+					op: {
+						visible: true,
+						props: {
+							width: 300,
+							align: 'center',
+							fixed: 'right',
+							label: '操作'
+						},
+						layout: ['slot-item-list','slot-modify']
+					}
+
+
+
+				})
+				.set('dict', {
+					search: {
+						keyWord: 'goodsName'
+					}
+				})
+				.set('search', {
+					key: {
+						placeholder: '分类名称'
+					}
+				})
+				.set('layout', [
+					['slot-tabs'],
+					['flex1', 'slot-add-goods-btn', 'refresh-btn'],
+					['data-table'],
+					['flex1', 'pagination']
+				])
+				.on('delete', (selection, { next }) => {
+					next({
+						id: selection.map(e => e.id).join(',')
+					});
+				})
+				.done();
+			app.refresh({ status: this.tabIndex });
+		},
+
+		refresh(params) {
+			this.app.refresh(params);
+		},
+
+		showSort(e) {
+			this.sort.status = true;
+		},
+
+		hideSort(e) {
+			this.sort.status = false;
+		},
+
+		changeSort(d) {
+			this.$service.goods
+				.sort({
+					inTurn: d.inTurn,
+					id: d.id
+				})
+				.then(() => {
+					this.$message.success('修改成功');
+					this.refresh();
+				})
+				.catch(err => {
+					this.$message.error(err);
+				});
+		}
+	}
+};
+</script>
+
+<style lang="scss" scoped>
+.short-link {
+	color: $mainColor;
+	margin-left: 10px;
+	cursor: pointer;
+}
+.set-sort {
+	display: flex;
+	align-items: center;
+	justify-content: center;
+	.el-button {
+		margin-left: 10px;
+	}
+	.show {
+		font-size: 16px;
+	}
+	.hide {
+		padding: 2px 5px;
+	}
+}
+</style>

+ 291 - 0
hd/src/views/item/list.vue

@@ -0,0 +1,291 @@
+<template>
+  <div class="app-list-content">
+    <x-crud
+      class="liu-crud-wrap"
+      @load="onLoad"
+    >
+      <template #slot-tabs>
+        <el-tabs
+          class="liu-tabs"
+          type="border-card"
+          v-model="tabIndex"
+          @tab-click="tabClick"
+        >
+          <el-tab-pane
+            v-for="(item, index) in tabsData"
+            :key="index"
+            :label="item.text"
+            :name="item.key"
+          >
+          </el-tab-pane>
+        </el-tabs>
+      </template>
+
+      <template #table-column-avatarUrl="{scope}">
+        <cl-avatar
+          shape="square"
+          :size="32"
+          :src="scope.row.smallImgList[0]"
+          :style="{ margin: 'auto' }"
+        ></cl-avatar>
+      </template>
+
+      <template #table-column-goodsName="{scope}">
+        <span>{{ scope.row.goodsName }}</span>
+      </template>
+
+      <template #table-column-inTurn="{scope}">
+        <span v-if="!sort.status">{{ scope.row.inTurn }}</span>
+        <el-input
+          ref="sort-input"
+          focus
+          size="mini"
+          v-else
+          v-model="scope.row.inTurn"
+          @blur="changeSort(scope.row)"
+        ></el-input>
+      </template>
+
+      <!-- 排序 -->
+      <template #table-header-inTurn>
+        <div class="set-sort">
+          <span>排序</span>
+          <el-button
+            v-if="!sort.status"
+            icon="el-icon-edit-outline"
+            size="small"
+            type="text"
+            @click="showSort"
+            class="show"
+          ></el-button>
+
+          <el-button
+            class="hide"
+            v-else
+            size="mini"
+            @click="hideSort"
+            type="primary"
+          >完成</el-button>
+        </div>
+      </template>
+      <template
+        #slot-add-goods-btn
+        v-if="showAddBtn"
+      >
+        <el-button
+          type="primary"
+          size="mini"
+          @click="add()"
+        >添加</el-button>
+      </template>
+    </x-crud>
+    <item-list-layer
+      :show.sync="showItemModal"
+      @confirm="selGoodsConfirmFn"
+      @cancel="showItemModal = false"
+    ></item-list-layer>
+
+  </div>
+</template>
+<script>
+import { mapGetters } from 'vuex';
+import itemListLayer from '@/components/module/item-list-layer';
+
+export default {
+  name: 'item_list',
+  components: {
+    itemListLayer
+  },
+  data () {
+    return {
+      app: null,
+      sortLink: '',
+      operateData: {},
+      tabIndex: '0',
+      tabsData: [
+        {
+          text: '花材列表',
+          key: '0'
+        }
+      ],
+      selects: {},
+      sort: {
+        status: false
+      },
+      classId: 0,
+      showAddBtn: false,
+      showItemModal: false,
+    };
+  },
+  computed: {
+  },
+  methods: {
+    selGoodsConfirmFn (item) {
+      let param = []
+      item.forEach(value => {
+        let newObj = {}
+        newObj.itemId = value.id
+        newObj.classId = this.classId
+        newObj.cost = value.cost
+        newObj.addPrice = value.addPrice
+        newObj.stockWarning = value.stockWarning
+        param.push(newObj)
+      })
+      param = JSON.stringify(param)
+      console.log(param)
+      this.$service.item.batchAdd({ data: param }).then(res => {
+        this.$message.success('操作成功!');
+        this.showItemModal = false
+        this.$router.go(0)
+      }).catch(err => { console.log(err) })
+    },
+    add () {
+      this.showItemModal = true
+    },
+    tabClick (tab, e) {
+      this.app.refresh({ classId: this.classId });
+    },
+    onLoad ({ ctx, app }) {
+      this.app = app;
+      if (this.$route.query.classId) {
+        this.classId = this.$route.query.classId
+        if (this.$route.query.name != '') {
+          this.tabsData[0].text = this.$route.query.name
+          this.$forceUpdate()
+          this.showAddBtn = true
+        }
+      } else {
+        this.showAddBtn = false
+      }
+      let getItem = () => {
+        return this.$service.item.list({ classId: this.classId })
+      };
+      ctx.service({
+        page: getItem
+      })
+        .set('table', {
+          columns: [
+            {
+              prop: 'id',
+              label: 'ID',
+              align: 'center'
+            },
+            {
+              prop: 'itemName',
+              label: '名称',
+              align: 'center',
+              'min-width': 180
+            },
+            {
+              prop: 'stockWarning',
+              label: '库存预警',
+              align: 'center',
+              'min-width': 100
+            },
+            {
+              prop: 'cost',
+              label: '成本价',
+              align: 'center',
+              'min-width': 100
+            },
+            {
+              prop: 'addPrice',
+              label: '加价',
+              align: 'center',
+              'min-width': 100
+            },
+            {
+              prop: 'inTurn',
+              label: '排序',
+              align: 'center',
+              minWidth: 100
+            },
+            {
+              prop: 'addTime',
+              label: '创建时间',
+              align: 'center',
+              minWidth: 180
+            }
+          ],
+          op: {
+            visible: true,
+            props: {
+              width: 300,
+              align: 'center',
+              fixed: 'right',
+              label: '操作'
+            },
+            layout: []
+          }
+        })
+        .set('dict', {
+          search: {
+            keyWord: 'goodsName'
+          }
+        })
+        .set('search', {
+          key: {
+            placeholder: '分类名称'
+          }
+        })
+        .set('layout', [
+          ['slot-tabs'],
+          ['flex1', 'slot-add-goods-btn', 'refresh-btn'],
+          ['data-table'],
+          ['flex1', 'pagination']
+        ])
+        .done();
+      app.refresh({ classId: this.classId });
+    },
+
+    refresh (params) {
+      this.app.refresh(params);
+    },
+
+    showSort (e) {
+      this.sort.status = true;
+    },
+
+    hideSort (e) {
+      this.sort.status = false;
+    },
+
+    changeSort (d) {
+      this.$service.goods
+        .sort({
+          inTurn: d.inTurn,
+          id: d.id
+        })
+        .then(() => {
+          this.$message.success('修改成功');
+          this.refresh();
+        })
+        .catch(err => {
+          this.$message.error(err);
+        });
+    }
+  }
+};
+</script>
+
+<style lang="scss" scoped>
+.short-link {
+  color: $mainColor;
+  margin-left: 10px;
+  cursor: pointer;
+}
+.set-sort {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  .el-button {
+    margin-left: 10px;
+  }
+  .show {
+    font-size: 16px;
+  }
+  .hide {
+    padding: 2px 5px;
+  }
+}
+</style>

+ 1 - 1
hdApp/src/pagesStorehouse/flower/category.vue

@@ -83,7 +83,7 @@ export default {
 					custom: "warn"
 				},
 				{
-					name: "每扎采购价",
+					name: "每扎成本",
 					width: 130,
 					color: "info",
 					align: "center",

+ 5 - 4
pt/src/cool/request/index.js

@@ -18,7 +18,6 @@ import single from '@/service/single/index';
 import setting from '@/service/setting/index';
 import workbench from '@/service/workbench/index';
 import auth from '@/service/auth/index';
-
 import saasShop from '@/service/saas/shop/index';
 import saasOrder from '@/service/saas/order/index';
 import saasMember from '@/service/saas/member/index';
@@ -26,11 +25,11 @@ import saasPtMember from '@/service/saas/pt-member/index';
 import saasFest from '@/service/saas/fest/index';
 import saasAuth from '@/service/saas/auth/index';
 import saasWxOpen from '@/service/saas/wx-open/index';
-
 import shop from '@/service/shop/index';
 import chat from '@/service/chat/index';
-
 import sj from '@/service/sj/index';
+import itemClass from '@/service/item-class/index';
+import item from '@/service/item/index';
 
 export function SET_SERVICE({ store }) {
 	// const files = require.context('@/service/', true, /\.js$/);
@@ -64,7 +63,9 @@ export function SET_SERVICE({ store }) {
 		saasWxOpen,
 		shop,
 		chat,
-		sj
+		sj,
+		itemClass,
+		item
 	};
 
 	Vue.prototype.$service = modules;

+ 33 - 0
pt/src/mock/userInfo.js

@@ -306,6 +306,39 @@ let menu = {
 			viewPath: 'saas/fest/list',
 			keepAlive: 1
 		},
+		{
+			id: '8',
+			parentId: null,
+			name: '花材',
+			type: 0,
+			icon: 'icongongzuotai',
+			orderNum: 4,
+			router: '/item-class/list',
+			viewPath: 'views/item-class/list.vue',
+			keepAlive: 1
+		},
+		{
+			id: '805',
+			parentId: '8',
+			name: '花材分类',
+			type: 1,
+			icon: 'icongongzuotai',
+			orderNum: 4,
+			router: '/item-class/list',
+			viewPath: 'views/item-class/list.vue',
+			keepAlive: 1
+		},
+		{
+			id: '810',
+			parentId: '8',
+			name: '花材列表',
+			type: 1,
+			icon: 'icongongzuotai',
+			orderNum: 4,
+			router: '/item/list',
+			viewPath: 'views/item/list.vue',
+			keepAlive: 1
+		},
 		{
 			id: '7',
 			parentId: null,

+ 27 - 0
pt/src/service/item-class/index.js

@@ -0,0 +1,27 @@
+import { BaseService, Service } from '@/cool';
+
+@Service('item-class')
+export class ItemClassService extends BaseService {
+
+	addClass(data) {
+		return this.request({
+			url: '/add',
+			method: 'POST',
+			data: data
+		});
+	}
+	updateClass(data) {
+		return this.request({
+			url: '/update',
+			method: 'POST',
+			data: data
+		});
+	}
+	deleteClass(data) {
+		return this.request({
+			url: '/delete',
+			params: data
+		});
+	}
+}
+export default new ItemClassService();

+ 27 - 0
pt/src/service/item/index.js

@@ -0,0 +1,27 @@
+import { BaseService, Service } from '@/cool';
+
+@Service('item')
+export class ItemService extends BaseService {
+    /**
+	 * 新增花材 b
+	 */
+	itemAdd(data) {
+		return this.request({
+			url: '/add',
+			method: 'POST',
+			data: data
+		});
+  }
+    /**
+	 * 批量新增花材 b
+	 */
+    batchAdd(data) {
+		return this.request({
+			url: '/batch-add',
+			method: 'POST',
+			data: data
+		});
+  }
+  
+}
+export default new ItemService();

+ 7 - 0
pt/src/service/pt-item/index.js

@@ -0,0 +1,7 @@
+import { BaseService, Service } from '@/cool';
+
+@Service('pt-item')
+export class PtItemService extends BaseService {
+
+}
+export default new PtItemService();

+ 328 - 0
pt/src/views/item-class/list.vue

@@ -0,0 +1,328 @@
+<template>
+	<div class="app-list-content">
+		<x-crud class="liu-crud-wrap" @load="onLoad">
+			<template #slot-tabs>
+				<el-tabs
+					class="liu-tabs"
+					type="border-card"
+					v-model="tabIndex"
+					@tab-click="handleClick"
+				>
+					<el-tab-pane
+						v-for="(item, index) in tabsData"
+						:key="index"
+						:label="item.text"
+						:name="item.key"
+					>
+					</el-tab-pane>
+				</el-tabs>
+			</template>
+
+			<template #table-column-num="{scope}">
+				<el-link
+					@click="getItemList(scope.row)"
+				>{{ scope.row.num }}</el-link>
+			</template>
+
+			<template #table-column-name="{scope}">
+				<el-link
+					@click="getItemList(scope.row)"
+				>{{ scope.row.name }}</el-link>
+			</template>
+
+			<template #table-column-inTurn="{scope}">
+				<span v-if="!sort.status">{{ scope.row.inTurn }}</span>
+				<el-input
+					ref="sort-input"
+					focus
+					size="mini"
+					v-else
+					v-model="scope.row.inTurn"
+					@blur="changeSort(scope.row)"
+				></el-input>
+			</template>
+
+			<!-- 排序 -->
+			<template #table-header-inTurn>
+				<div class="set-sort">
+					<span>排序</span>
+					<el-button
+						v-if="!sort.status"
+						icon="el-icon-edit-outline"
+						size="small"
+						type="text"
+						@click="showSort"
+						class="show"
+					></el-button>
+
+					<el-button class="hide" v-else size="mini" @click="hideSort" type="primary"
+						>完成</el-button
+					>
+				</div>
+			</template>
+
+			<!-- 添加分类 -->
+			<template #slot-add-goods-btn>
+				<el-button type="primary" size="mini" @click="replaceBtnFn(0)">添加</el-button>
+			</template>
+
+			<template #slot-item-list="{scope}">
+				<el-button type="text" @click.native.stop="getItemList(scope.row)">花材列表</el-button>
+			</template>
+
+			<template #slot-modify="{scope}">
+				<el-button type="text" @click.native.stop="replaceBtnFn(scope.row.id,scope.row.name)">修改</el-button>
+			</template>
+
+		</x-crud>
+
+
+		<!-- 新增弹窗 -->
+		<el-dialog
+			:title="`${id == 0 ? '添加' : '修改'}花材`"
+			:visible.sync="replaceDialog"
+			:close-on-click-modal="false"
+			width="600px"
+		>
+			<div class="ad-modal-content">
+				<el-form :model="replaceForm" :rules="ruleForm" ref="replaceForm" label-width="100px" class="demo-form">
+					<el-form-item label="分类名称" prop="name">
+						<el-input v-model="replaceForm.name" placeholder="请输入名称" size="small"></el-input>
+					</el-form-item>
+				</el-form>
+			</div>
+			<div slot="footer" class="dialog-footer">
+				<el-button size="small" @click="resetForm">取 消</el-button>
+				<el-button type="primary" size="small" @click="submitForm('replaceForm')">确认</el-button>
+			</div>
+		</el-dialog>
+
+
+	</div>
+</template>
+
+<script>
+import { mapGetters } from 'vuex';
+
+export default {
+	data() {
+		return {
+			app: null,
+			sortLink: '',
+			operateData: {},
+			tabIndex: '0',
+			tabsData: [
+				{
+					text: '花材分类',
+					key: '0'
+				}
+			],
+			selects: {},
+			sort: {
+				status: false
+			},
+			replaceDialog:false,
+			id:0,
+			replaceForm: {
+				name: ''
+			},
+			ruleForm: {
+				name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
+			},
+		};
+	},
+	computed: {
+	},
+	methods: {
+		deleteFn(id){
+			let self = this
+			this.$confirm('确认删除?', '提示', {
+				confirmButtonText: '确定',
+				cancelButtonText: '取消',
+				type: 'warning'
+			}).then(() => {
+				this.$service.itemClass.deleteClass({id:id}).then(res => {
+					self.replaceDialog = false
+					self.app.refresh();
+				});
+			});
+		},
+		resetForm(){
+			this.$refs['replaceForm'].resetFields();
+			this.replaceDialog = false
+		},
+		replaceFn() {
+			let replaceForm = JSON.parse(JSON.stringify(this.replaceForm));
+			let self = this
+			if (self.id == 0) {
+				this.$service.itemClass.addClass(replaceForm).then(res => {
+					self.replaceDialog = false
+					self.resetForm();
+					self.app.refresh();
+				});
+			} else {
+				this.$service.itemClass.updateClass({id:self.id,...replaceForm}).then(res => {
+					self.replaceDialog = false
+					self.resetForm();
+					self.app.refresh();
+				});
+			}
+		},
+		submitForm(formName) {
+			this.$refs[formName].validate(valid => {
+				if (valid) {
+					this.replaceFn();
+				} else {
+					console.log('error submit!!');
+					return false;
+				}
+			});
+		},
+		replaceBtnFn(id,name) {
+			this.id = id
+			this.replaceForm.name = name
+			this.replaceDialog = true
+		},
+		handleClick(tab, e) {
+			this.app.refresh({ type: this.tabIndex });
+		},
+		//添加花材
+		getItemList(data) {
+			let query = {};
+			query.classId = data.id
+			query.name = data.name
+			this.$router.push({ path: '/item/list', query });
+		},
+		// x-crud 组件
+		onLoad({ ctx, app }) {
+			this.app = app;
+			ctx.service(this.$service.itemClass)
+				.set('table', {
+					columns: [
+						{
+							prop: 'id',
+							label: 'ID',
+							align: 'center'
+						},
+						{
+							prop: 'name',
+							label: '标题',
+							align: 'center',
+							'min-width': 180
+						},
+						{
+							prop: 'num',
+							label: '花材数量',
+							align: 'center',
+							'min-width': 100
+						},
+						{
+							prop: 'inTurn',
+							label: '排序',
+							align: 'center',
+							minWidth: 100
+						},
+						{
+							prop: 'addTime',
+							label: '创建时间',
+							align: 'center',
+							minWidth: 180
+						}
+					],
+
+					on: {
+						'row-click': (row, column) => {
+							this.getItemList(row)
+						}
+					},
+
+					op: {
+						visible: true,
+						props: {
+							width: 300,
+							align: 'center',
+							fixed: 'right',
+							label: '操作'
+						},
+						layout: ['slot-item-list','slot-modify']
+					}
+
+
+
+				})
+				.set('dict', {
+					search: {
+						keyWord: 'goodsName'
+					}
+				})
+				.set('search', {
+					key: {
+						placeholder: '分类名称'
+					}
+				})
+				.set('layout', [
+					['slot-tabs'],
+					['flex1', 'slot-add-goods-btn', 'refresh-btn'],
+					['data-table'],
+					['flex1', 'pagination']
+				])
+				.on('delete', (selection, { next }) => {
+					next({
+						id: selection.map(e => e.id).join(',')
+					});
+				})
+				.done();
+			app.refresh({ status: this.tabIndex });
+		},
+
+		refresh(params) {
+			this.app.refresh(params);
+		},
+
+		showSort(e) {
+			this.sort.status = true;
+		},
+
+		hideSort(e) {
+			this.sort.status = false;
+		},
+
+		changeSort(d) {
+			this.$service.goods
+				.sort({
+					inTurn: d.inTurn,
+					id: d.id
+				})
+				.then(() => {
+					this.$message.success('修改成功');
+					this.refresh();
+				})
+				.catch(err => {
+					this.$message.error(err);
+				});
+		}
+	}
+};
+</script>
+
+<style lang="scss" scoped>
+.short-link {
+	color: $mainColor;
+	margin-left: 10px;
+	cursor: pointer;
+}
+.set-sort {
+	display: flex;
+	align-items: center;
+	justify-content: center;
+	.el-button {
+		margin-left: 10px;
+	}
+	.show {
+		font-size: 16px;
+	}
+	.hide {
+		padding: 2px 5px;
+	}
+}
+</style>

+ 284 - 0
pt/src/views/item/list.vue

@@ -0,0 +1,284 @@
+<template>
+  <div class="app-list-content">
+    <x-crud
+      class="liu-crud-wrap"
+      @load="onLoad"
+    >
+      <template #slot-tabs>
+        <el-tabs
+          class="liu-tabs"
+          type="border-card"
+          v-model="tabIndex"
+          @tab-click="tabClick"
+        >
+          <el-tab-pane
+            v-for="(item, index) in tabsData"
+            :key="index"
+            :label="item.text"
+            :name="item.key"
+          >
+          </el-tab-pane>
+        </el-tabs>
+      </template>
+
+      <template #table-column-avatarUrl="{scope}">
+        <cl-avatar
+          shape="square"
+          :size="32"
+          :src="scope.row.smallImgList[0]"
+          :style="{ margin: 'auto' }"
+        ></cl-avatar>
+      </template>
+
+      <template #table-column-goodsName="{scope}">
+        <span>{{ scope.row.goodsName }}</span>
+      </template>
+
+      <template #table-column-inTurn="{scope}">
+        <span v-if="!sort.status">{{ scope.row.inTurn }}</span>
+        <el-input
+          ref="sort-input"
+          focus
+          size="mini"
+          v-else
+          v-model="scope.row.inTurn"
+          @blur="changeSort(scope.row)"
+        ></el-input>
+      </template>
+
+      <!-- 排序 -->
+      <template #table-header-inTurn>
+        <div class="set-sort">
+          <span>排序</span>
+          <el-button
+            v-if="!sort.status"
+            icon="el-icon-edit-outline"
+            size="small"
+            type="text"
+            @click="showSort"
+            class="show"
+          ></el-button>
+
+          <el-button
+            class="hide"
+            v-else
+            size="mini"
+            @click="hideSort"
+            type="primary"
+          >完成</el-button>
+        </div>
+      </template>
+      <template
+        #slot-add-goods-btn
+        v-if="showAddBtn"
+      >
+        <el-button
+          type="primary"
+          size="mini"
+          @click="add()"
+        >添加</el-button>
+      </template>
+    </x-crud>
+
+  </div>
+</template>
+<script>
+import { mapGetters } from 'vuex';
+
+export default {
+  name: 'item_list',
+  components: {
+  },
+  data () {
+    return {
+      app: null,
+      sortLink: '',
+      operateData: {},
+      tabIndex: '0',
+      tabsData: [
+        {
+          text: '花材列表',
+          key: '0'
+        }
+      ],
+      selects: {},
+      sort: {
+        status: false
+      },
+      classId: 0,
+      showAddBtn: false,
+      showItemModal: false,
+    };
+  },
+  computed: {
+  },
+  methods: {
+    selGoodsConfirmFn (item) {
+      let param = []
+      item.forEach(value => {
+        let newObj = {}
+        newObj.itemId = value.id
+        newObj.classId = this.classId
+        newObj.cost = value.cost
+        newObj.addPrice = value.addPrice
+        newObj.stockWarning = value.stockWarning
+        param.push(newObj)
+      })
+      param = JSON.stringify(param)
+      console.log(param)
+      this.$service.item.batchAdd({ data: param }).then(res => {
+        this.$message.success('操作成功!');
+        this.showItemModal = false
+        this.$router.go(0)
+      }).catch(err => { console.log(err) })
+    },
+    add () {
+      this.showItemModal = true
+    },
+    tabClick (tab, e) {
+      this.app.refresh({ classId: this.classId });
+    },
+    onLoad ({ ctx, app }) {
+      this.app = app;
+      if (this.$route.query.classId) {
+        this.classId = this.$route.query.classId
+        if (this.$route.query.name != '') {
+          this.tabsData[0].text = this.$route.query.name
+          this.$forceUpdate()
+          this.showAddBtn = true
+        }
+      } else {
+        this.showAddBtn = false
+      }
+      let getItem = () => {
+        return this.$service.item.list({ classId: this.classId })
+      };
+      ctx.service({
+        page: getItem
+      })
+        .set('table', {
+          columns: [
+            {
+              prop: 'id',
+              label: 'ID',
+              align: 'center'
+            },
+            {
+              prop: 'name',
+              label: '名称',
+              align: 'center',
+              'min-width': 180
+            },
+            {
+              prop: 'stockWarning',
+              label: '库存预警',
+              align: 'center',
+              'min-width': 100
+            },
+            {
+              prop: 'cost',
+              label: '成本价',
+              align: 'center',
+              'min-width': 100
+            },
+            {
+              prop: 'addPrice',
+              label: '加价',
+              align: 'center',
+              'min-width': 100
+            },
+            {
+              prop: 'inTurn',
+              label: '排序',
+              align: 'center',
+              minWidth: 100
+            },
+            {
+              prop: 'addTime',
+              label: '创建时间',
+              align: 'center',
+              minWidth: 180
+            }
+          ],
+          op: {
+            visible: true,
+            props: {
+              width: 300,
+              align: 'center',
+              fixed: 'right',
+              label: '操作'
+            },
+            layout: []
+          }
+        })
+        .set('dict', {
+          search: {
+            keyWord: 'goodsName'
+          }
+        })
+        .set('search', {
+          key: {
+            placeholder: '分类名称'
+          }
+        })
+        .set('layout', [
+          ['slot-tabs'],
+          ['flex1', 'slot-add-goods-btn', 'refresh-btn'],
+          ['data-table'],
+          ['flex1', 'pagination']
+        ])
+        .done();
+      app.refresh({ classId: this.classId });
+    },
+
+    refresh (params) {
+      this.app.refresh(params);
+    },
+
+    showSort (e) {
+      this.sort.status = true;
+    },
+
+    hideSort (e) {
+      this.sort.status = false;
+    },
+
+    changeSort (d) {
+      this.$service.goods
+        .sort({
+          inTurn: d.inTurn,
+          id: d.id
+        })
+        .then(() => {
+          this.$message.success('修改成功');
+          this.refresh();
+        })
+        .catch(err => {
+          this.$message.error(err);
+        });
+    }
+  }
+};
+</script>
+
+<style lang="scss" scoped>
+.short-link {
+  color: $mainColor;
+  margin-left: 10px;
+  cursor: pointer;
+}
+.set-sort {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  .el-button {
+    margin-left: 10px;
+  }
+  .show {
+    font-size: 16px;
+  }
+  .hide {
+    padding: 2px 5px;
+  }
+}
+</style>