Просмотр исходного кода

Merge branch 'master' of http://git.huaml.com/zhh/front-end

wangn 5 лет назад
Родитель
Сommit
e7ff8de1ee

+ 0 - 471
hd/src/views/staff/list.vue

@@ -1,471 +0,0 @@
-<template>
-	<div class="app-list-content">
-		<x-crud class="liu-crud-wrap" @load="onLoad">
-			<template #table-column-userId="{scope}">
-				<i class="el-icon-success" v-if="scope.row.userId != 0" style="color:#67C23A;font-size:19px;"></i>
-				<i class="el-icon-success" v-else style="color:#C0C4CC;font-size:19px;"></i>
-			</template>
-			<template #table-column-avatar="{scope}">
-				<cl-avatar shape="circle" :size="24" :src="scope.row.avatarUrl" :style="{ margin: 'auto' }"></cl-avatar>
-			</template>
-
-			<template #table-column-incomeNotice="{scope}">
-				<el-switch
-					v-model="scope.row.remind"
-					active-value="1"
-					inactive-value="0"
-					@change="
-						v => {
-							changeNotice(scope.row.id, v);
-						}
-					"
-				></el-switch>
-			</template>
-
-			<template #table-column-status="{scope}">
-				<el-switch
-					v-model="scope.row.status"
-					active-value="1"
-					inactive-value="0"
-					@change="
-						v => {
-							changeStatus(scope.row.id, v);
-						}
-					"
-				></el-switch>
-			</template>
-
-			<!-- 权限设置 -->
-			<!-- <template #slot-auth="{scope}">
-				<el-button type="text" @click="authBtnFn(scope.row)">权限设置</el-button>
-			</template>-->
-			<!-- 编辑 -->
-			<!--
-			<template #slot-modify="{scope}">
-				<el-button type="text" @click="modifyBtnFn(scope.row)">编辑</el-button>
-			</template>
-			-->
-
-			<!-- 删除 -->
-			<!--
-			<template #slot-del="{scope}">
-				<el-button type="text" @click="delBtnFn(scope.row)">删除</el-button>
-			</template>
-			-->
-
-			<!-- 添加 -->
-			<template #slot-add-ad-btn="{scope}">
-				<el-button type="primary" size="mini" @click="addBtnFn">添加</el-button>
-			</template>
-		</x-crud>
-
-		<el-dialog title="请员工扫下方图片完成绑定" :visible.sync="showMiniCode" width="600px">
-			<div style="text-align:center;">
-				<img :src="miniCodeSrc" style="margin:0 auto;width:280px;" />
-			</div>
-			<span slot="footer" class="dialog-footer">
-				<el-button @click="showMiniCode = false">取 消</el-button>
-				<el-button type="primary" @click="showMiniCode = false">确 定</el-button>
-			</span>
-		</el-dialog>
-
-		<!-- 新增弹窗 -->
-		<el-dialog
-			:title="`${addOrModify == 1 ? '添加' : '修改'}员工`"
-			:visible.sync="addDialog"
-			:close-on-click-modal="false"
-			width="600px"
-		>
-			<div class="ad-modal-content">
-				<el-form :model="adForm" :rules="ruleForm" ref="adForm" label-width="100px" class="demo-form">
-					<el-form-item label="姓名" prop="adminName">
-						<el-input v-model="adForm.adminName" placeholder="请输入姓名" size="small"></el-input>
-					</el-form-item>
-					<el-form-item label="角色" prop="roleId">
-						<el-select v-model="adForm.roleName" size="small" placeholder="请选择角色" @change="selRoleFn">
-							<el-option
-								v-for="(item, index) in roleList"
-								:key="index"
-								:value="item.roleName"
-							>{{ item.roleName }}</el-option>
-						</el-select>
-					</el-form-item>
-					<!--
-					<el-form-item label="绑定小程序" prop="userId">
-						<div>
-							<div class="member-wrap flex-center" v-if="!$util.isEmpty(memberData)">
-								<div class="member-img">
-									<cl-avatar
-										shape="circle"
-										:size="40"
-										:src="memberData.avatarUrl | default_avatar"
-									></cl-avatar>
-								</div>
-								<div class="member-det">
-									<div class="app-size-28">{{ memberData.userName }}</div>
-									<div>{{ memberData.mobile }}</div>
-								</div>
-							</div>
-							<div>
-								<el-button type="primary" size="small" @click="selGoods"
-									>请选择</el-button
-								>
-							</div>
-						</div>
-					</el-form-item>
-					-->
-					<el-form-item label="登陆密码" prop="password">
-						<el-input v-model="adForm.password" placeholder="请输入登录密码" type="password" size="small"></el-input>
-					</el-form-item>
-					<el-form-item label="备注">
-						<el-input v-model="adForm.remark" type="textarea" size="small"></el-input>
-					</el-form-item>
-					<el-form-item label="收款通知" prop="remind">
-						<el-switch v-model="adForm.remind" active-value="1" inactive-value="0"></el-switch>
-					</el-form-item>
-					<el-form-item label="启用状态" prop="status">
-						<el-switch v-model="adForm.status" active-value="1" inactive-value="0"></el-switch>
-					</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('adForm')">确认</el-button>
-			</div>
-		</el-dialog>
-		<!-- 选择商品 -->
-		<sel-member
-			:show.sync="selMemberModal"
-			@confirm="selMemberConfirmFn"
-			@cancel="selMemberModal = false"
-		></sel-member>
-		<!-- 权限设置 -->
-		<role-set :show.sync="roleShow" :info="modifyData" />
-	</div>
-</template>
-
-<script>
-import selMember from '@/components/module/sel-member';
-import roleSet from '@/components/role-set';
-
-export default {
-	name: 'list-ad',
-	components: {
-		selMember,
-		roleSet
-	},
-	data() {
-		return {
-			app: null,
-			// 修改弹窗
-			modifyData: {},
-			// 新增或者修改弹窗
-			addOrModify: 1,
-			addDialog: false,
-			showMiniCode: false,
-			miniCodeSrc: '',
-			adForm: {
-				adminName: '',
-				roleId: '',
-				roleName: '',
-				remind: '1',
-				password: '',
-				userId: '',
-				remark: '',
-				status: '1'
-			},
-			ruleForm: {
-				adminName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
-				roleName: [{ required: true, message: '请选择角色', trigger: 'change' }],
-				//userId: [{ required: true, message: '请选择会员', trigger: 'blur' }],
-				password: { required: true, message: '请输入密码', trigger: 'blur' }
-			},
-			// 角色列表
-			roleList: [],
-			// 商品列表
-			selMemberModal: false,
-			memberData: {},
-			// 权限设置
-			roleShow: false
-		};
-	},
-	methods: {
-		// api
-		getRole() {
-			if (!this.$util.isEmpty(this.roleList)) return this.roleList;
-			this.$service.role.list().then(res => {
-				this.roleList = res.list;
-			});
-		},
-		delBtnFn(item) {
-			this.$confirm('是否删除该员工?', '提示', {
-				confirmButtonText: '确定',
-				cancelButtonText: '取消',
-				type: 'warning'
-			})
-				.then(() => {
-					this.$service.staff.delete({ id: item.id }).then(res => {
-						this.$message.success('删除成功!');
-						this.app.refresh({ type: this.tabIndex });
-					});
-				})
-				.catch();
-		},
-		// operate
-		authBtnFn(item) {
-			this.modifyData = item;
-			this.roleShow = true;
-		},
-		modifyBtnFn(item) {
-			this.$service.staff
-				.info({
-					id: item.id
-				})
-				.then(async staffInfo => {
-					let memberInfo = {};
-
-					if (staffInfo.userId && staffInfo.userId != '0') {
-						memberInfo = await this.$service.member.info({ userId: staffInfo.userId });
-					}
-
-					this.getRole();
-
-					this.memberData = memberInfo;
-
-					this.addOrModify = 2;
-					this.modifyData = staffInfo;
-					this.addDialog = true;
-					let data = JSON.parse(JSON.stringify(staffInfo));
-					data.startTime = this.$util.$formatDate(data.startTime);
-					data.endTime = this.$util.$formatDate(data.endTime);
-					if (this.$util.isEmpty(data)) return;
-					Object.keys(this.adForm).forEach(i => {
-						// if (i == 'password') return false;
-						this.adForm[i] = data[i];
-					});
-
-					this.ruleForm.password.required = false;
-				});
-		},
-		addBtnFn() {
-			this.getRole();
-			this.addOrModify = 1;
-			this.addDialog = true;
-			this.memberData = {};
-
-			this.adForm = {
-				adminName: '',
-				roleId: '',
-				roleName: '',
-				remind: '1',
-				password: '',
-				userId: '',
-				remark: '',
-				status: '1'
-			};
-
-			this.ruleForm.password.required = true;
-		},
-		// 切换收款通知
-		changeNotice(id, val) {
-			this.$service.common.updateRemind({ id, remind: val }).then(res => {
-				this.$message.success('操作成功!');
-				this.app.refresh();
-			});
-		},
-		// 启用状态
-		changeStatus(id, val) {
-			this.$service.common.updateStatus({ id, status: val }).then(res => {
-				this.$message.success('操作成功!');
-				this.app.refresh();
-			});
-		},
-		// dialog
-		selRoleFn(val) {
-			let index = this.roleList.findIndex(e => e.roleName == val);
-			this.adForm.roleId = this.roleList[index].id;
-			console.log('this.adForm.roleId', this.adForm.roleId);
-		},
-		resetForm() {
-			this.$refs['adForm'].resetFields();
-			this.memberData = {};
-			this.addDialog = false;
-		},
-
-		addFn() {
-			let adForm = JSON.parse(JSON.stringify(this.adForm));
-			let host = null;
-			delete adForm.roleName;
-			if (this.addOrModify == 1) {
-				host = () => {
-					return this.$service.shopAdmin.prepareBind(this.adForm);
-				};
-			} else {
-				host = () => {
-					return this.$service.shopAdmin.update({
-						id: this.modifyData.id,
-						...adForm
-					});
-				};
-			}
-			host(adForm).then(res => {
-				this.miniCodeSrc = res.miniCode;
-				this.showMiniCode = true;
-
-				//this.$message.success('操作成功!');
-				this.resetForm();
-				this.app.refresh({ type: this.tabIndex });
-			});
-		},
-		// 选择会员
-		selGoods() {
-			this.selMemberModal = true;
-			setTimeout(() => {
-				console.log(this.memberData);
-			}, 6000);
-		},
-		selMemberConfirmFn(item) {
-			this.memberData = item;
-			this.adForm.userId = item.id;
-			this.selMemberModal = false;
-		},
-		submitForm(formName) {
-			this.$refs[formName].validate(valid => {
-				if (valid) {
-					this.addFn();
-				} else {
-					console.log('error submit!!');
-					return false;
-				}
-			});
-		},
-		// x-crud 组件ad
-		onLoad({ ctx, app }) {
-			this.app = app;
-			ctx.service(this.$service.shopAdmin)
-				.set('table', {
-					columns: [
-						{
-							prop: 'id',
-							label: 'id',
-							align: 'center',
-							width: 60
-						},
-						{
-							prop: 'avatar',
-							label: '头像',
-							align: 'center',
-							width: 90,
-							formatter: row => {
-								return row.adminBaseInfo.avatarUrl;
-							}
-						},
-						{
-							prop: 'adminName',
-							label: '姓名',
-							align: 'center',
-							formatter: row => {
-								return row.adminBaseInfo.adminName;
-							}
-						},
-						{
-							prop: 'mobile',
-							label: '手机号',
-							align: 'center',
-							formatter: row => {
-								return row.adminBaseInfo.mobile;
-							}
-						},
-						{
-							prop: 'roleName',
-							label: '角色',
-							align: 'center'
-						},
-						{
-							prop: 'userId',
-							label: '绑定小程序',
-							align: 'center',
-							'min-width': 80
-						},
-						{
-							prop: 'incomeNotice',
-							label: '收款通知',
-							align: 'center'
-						},
-						{
-							prop: 'addDate',
-							label: '添加时间',
-							align: 'center'
-						},
-						{
-							prop: 'lastLoginTime',
-							label: '最后登录',
-							align: 'center',
-							formatter: row => {
-								if (row.loginTime == '0') {
-									return '-';
-								}
-								return row.lastLoginTime;
-							}
-						},
-						{
-							prop: 'status',
-							label: '启用状态',
-							align: 'center'
-						}
-					],
-					// 操作列
-					op: {
-						visible: true, // 是否显示
-						// 同 element-ui Table-column Attributes
-						props: {
-							width: 120,
-							align: 'center',
-							fixed: 'right',
-							label: '操作'
-						},
-						// 布局,请移步 `layout`
-						layout: ['slot-auth', 'slot-modify', 'slot-del']
-					}
-				})
-				.set('layout', [
-					['slot-tabs'],
-					['flex1', 'slot-add-ad-btn', 'refresh-btn'],
-					['data-table'],
-					['flex1', 'pagination']
-				])
-				// .on('refresh', async (params, { next, render }) => {
-				// 	// 继续执行刷新
-				// 	let { list } = await next(params);
-				// 	list.map((e, index) => {
-				// 		e.index = index;
-				// 		e.imgUrl = e.smallImgList[0];
-				// 	});
-				// 	this.list = list;
-				// 	render(list);
-				// })
-				.done();
-			app.refresh({ type: this.tabIndex });
-		},
-		resetForm(formName) {
-			let formNamed = formName || 'form';
-			this.$refs[formNamed].resetFields();
-			this.addDialog = false;
-		},
-	}
-};
-</script>
-
-<style lang="scss" scoped>
-// module
-.ad-modal-content {
-	.member-wrap {
-		line-height: 1.4;
-		margin-bottom: 10px;
-		.member-det {
-			font-size: 12px;
-			margin-left: 10px;
-		}
-	}
-}
-</style>

+ 3 - 1
pt/src/cool/request/index.js

@@ -30,6 +30,7 @@ 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';
+import unit from '@/service/unit/index';
 
 export function SET_SERVICE({ store }) {
 	// const files = require.context('@/service/', true, /\.js$/);
@@ -65,7 +66,8 @@ export function SET_SERVICE({ store }) {
 		chat,
 		sj,
 		itemClass,
-		item
+		item,
+		unit
 	};
 
 	Vue.prototype.$service = modules;

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

@@ -23,5 +23,13 @@ export class ItemClassService extends BaseService {
 			params: data
 		});
 	}
+
+	getAllClass(data) {
+		return this.request({
+			url: '/get-all-class',
+			params: data
+		});
+	}
+
 }
 export default new ItemClassService();

+ 13 - 0
pt/src/service/unit/index.js

@@ -0,0 +1,13 @@
+import { BaseService, Service } from '@/cool';
+@Service('unit')
+export class UnitService extends BaseService {
+
+	getAllUnit(data) {
+		return this.request({
+			url: '/get-all-unit',
+			params: data
+		});
+	}
+
+}
+export default new UnitService();

+ 496 - 259
pt/src/views/item/list.vue

@@ -1,284 +1,521 @@
 <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>
+	<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-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-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-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>
+			<template #slot-modify="{ scope }">
+				<el-button
+					type="text"
+					@click.native.stop="replaceBtnFn(scope.row.id, scope.row.name)"
+					>修改</el-button
+				>
+			</template>
 
-          <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>
+			<!-- 排序 -->
+			<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>
 
-  </div>
+					<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="addBtn">添加</el-button>
+			</template>
+		</x-crud>
+
+		<!-- 新增弹窗 -->
+		<el-dialog
+			:title="`${addOrModify == 1 ? '添加' : '修改'}花材`"
+			:visible.sync="addDialog"
+			:close-on-click-modal="false"
+			width="600px"
+		>
+			<div class="ad-modal-content">
+				<el-form
+					:model="adForm"
+					:rules="adFormRules"
+					ref="adForm"
+					label-width="100px"
+					class="demo-form"
+				>
+					<el-form-item label="名称" prop="name">
+						<el-input
+							v-model="adForm.name"
+							placeholder="请输入名称"
+							size="small"
+						></el-input>
+					</el-form-item>
+
+					<el-form-item label="别名" prop="alias">
+						<el-input
+							v-model="adForm.alias"
+							placeholder="请输入别名"
+							size="small"
+						></el-input>
+					</el-form-item>
+
+					<el-form-item label="图片" prop="adImg">
+						<cl-upload v-model="adForm.adImg" :success="uploadSuccess"></cl-upload>
+						<p style="font-size: 14px; color: #cccccc">建议上传图片比例 400X400</p>
+					</el-form-item>
+
+					<el-form-item label="分类" prop="classId">
+						<el-select
+							v-model="adForm.className"
+							size="small"
+							placeholder="请选择分类"
+							@change="selClassFn"
+						>
+							<el-option
+								v-for="(item, index) in itemClassList"
+								:key="index"
+								:value="item.name"
+								>{{ item.name }}</el-option
+							>
+						</el-select>
+					</el-form-item>
+
+					<el-form-item label="大单位" prop="bigUnitId">
+						<el-select
+							v-model="adForm.bigUnitName"
+							size="small"
+							placeholder="请选择单位"
+							@change="selBigUnitFn"
+						>
+							<el-option
+								v-for="(item, index) in unitList"
+								:key="index"
+								:value="item.name"
+								>{{ item.name }}</el-option
+							>
+						</el-select>
+					</el-form-item>
+
+					<el-form-item label="小单位" prop="samllUnitId">
+						<el-select
+							v-model="adForm.samllUnitName"
+							size="small"
+							placeholder="请选择单位"
+							@change="selSmallUnitFn"
+						>
+							<el-option
+								v-for="(item, index) in unitList"
+								:key="index"
+								:value="item.name"
+								>{{ item.name }}</el-option
+							>
+						</el-select>
+					</el-form-item>
+
+					<el-form-item label="单位比" prop="ratio">
+						<el-input
+							v-model="adForm.ratio"
+							placeholder="1扎=20支,请输入20"
+							size="small"
+						></el-input>
+					</el-form-item>
+
+					<el-form-item label="库存预警" prop="stockWarning">
+						<el-input
+							v-model="adForm.stockWarning"
+							placeholder="请输入别名"
+							size="small"
+						></el-input>
+					</el-form-item>
+
+
+					<el-form-item label="每扎成本价" prop="cost">
+						<el-input
+							v-model="adForm.cost"
+							placeholder="请输入别名"
+							size="small"
+						></el-input>
+					</el-form-item>
+
+
+					<el-form-item label="每扎加价" prop="addPrice">
+						<el-input
+							v-model="adForm.addPrice"
+							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="addFn">确认</el-button>
+			</div>
+		</el-dialog>
+	</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 });
-    },
+	name: 'item_list',
+	components: {},
+	data() {
+		return {
+			app: null,
+			sortLink: '',
+			operateData: {},
+			tabIndex: '0',
+			tabsData: [
+				{
+					text: '花材列表',
+					key: '0',
+				},
+			],
+			selects: {},
+			sort: {
+				status: false,
+			},
+			classId: 0,
+			addDialog: false,
+			adForm: {
+				name: '',
+				alias: '',
+				classId: '',
+				className: '',
+				adImg: '',
+				bigUnitName: '',
+				bigUnitId: '',
+				smallUnitName: '',
+				smallUnitId: '',
+        stockWarning:'',
+        cost:'',
+        addPrice:''
+			},
+			addOrModify: 1,
+			adFormRules: {
+				name: {
+					required: true,
+					message: '广告图名称不能为空',
+				},
+				adImg: {
+					required: true,
+					message: '广告图片不能为空',
+				},
+				style: {
+					validator: (rule, value, callback) => {
+						const { url, style } = this.adForm;
+						if (style == '0') {
+							if (!url) {
+								//return callback(new Error('链接不能为空'));
+							}
+						} else {
+							if (!this.goodsData.id) {
+								return callback(new Error('请选择商品'));
+							}
+						}
+
+						callback();
+					},
+				},
+			},
+			//分类列表
+			itemClassList: [],
+			unitList: [],
+		};
+	},
+	computed: {},
+	methods: {
+		selClassFn(val) {
+			let index = this.itemClassList.findIndex((e) => e.name == val);
+			this.adForm.classId = this.itemClassList[index].id;
+		},
+		selBigUnitFn(val) {
+			let index = this.unitList.findIndex((e) => e.name == val);
+			this.adForm.bigUnitId = this.unitList[index].id;
+		},
+		selSmallUnitFn(val) {
+			let index = this.unitList.findIndex((e) => e.name == val);
+			this.adForm.smallUnitId = this.unitList[index].id;
+		},
+		getAllClass() {
+			if (!this.$util.isEmpty(this.itemClassList)) {
+				return this.itemClassList;
+			}
+			this.$service.itemClass.getAllClass().then((res) => {
+				this.itemClassList = res.list;
+			});
+		},
+		getAllUnit() {
+			if (!this.$util.isEmpty(this.unitList)) {
+				return this.unitList;
+			}
+			this.$service.unit.getAllUnit().then((res) => {
+				this.unitList = res.list;
+			});
+		},
+		uploadSuccess() {
+			this.$refs['adForm'].validateField('adImg');
+		},
+		addBtn() {
+			this.getAllClass()
+			this.getAllUnit()
+			this.addDialog = true
+			this.adForm = {
+				name: '',
+				alias: '',
+				adImg: '',
+				bigUnitName: '',
+				bigUnitId: '',
+				smallUnitName: '',
+				smallUnitId: '',
+        stockWarning:'',
+        cost:'',
+        addPrice:''
+			}
+		},
+		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.$router.go(0);
+				})
+				.catch((err) => {
+					console.log(err);
+				});
+		},
+		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();
+				}
+			}
+			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: ['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'],
+				])
+				.done();
+			app.refresh({ classId: this.classId });
+		},
 
-    refresh (params) {
-      this.app.refresh(params);
-    },
+		refresh(params) {
+			this.app.refresh(params);
+		},
 
-    showSort (e) {
-      this.sort.status = true;
-    },
+		showSort(e) {
+			this.sort.status = true;
+		},
 
-    hideSort (e) {
-      this.sort.status = false;
-    },
+		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);
-        });
-    }
-  }
+		changeSort(d) {
+			this.$service.goods
+				.sort({
+					inTurn: d.inTurn,
+					id: d.id,
+				})
+				.then(() => {
+					this.$message.success('修改成功');
+					this.refresh();
+				})
+				.catch((err) => {
+					this.$message.error(err);
+				});
+		},
+		resetForm() {
+			this.goodsData = {};
+			this.$refs['adForm'].resetFields();
+			this.addDialog = false;
+		},
+		addFn() {
+			this.$refs.adForm.validate((valid) => {
+				if (valid) {
+					let form = JSON.parse(JSON.stringify(this.adForm));
+					let host = null;
+					if (this.addOrModify == 1) {
+						host = () => {
+							return this.$service.ad.add(form);
+						};
+					} else {
+						host = () => {
+							return this.$service.ad.update({
+								id: this.modifyData.id,
+								...form,
+							});
+						};
+					}
+					host().then((res) => {
+						this.$message.success('操作成功!');
+						this.resetForm();
+						this.app.refresh({ type: this.tabIndex });
+					});
+				}
+			});
+		},
+	},
 };
 </script>
 
 <style lang="scss" scoped>
 .short-link {
-  color: $mainColor;
-  margin-left: 10px;
-  cursor: pointer;
+	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;
-  }
+	display: flex;
+	align-items: center;
+	justify-content: center;
+	.el-button {
+		margin-left: 10px;
+	}
+	.show {
+		font-size: 16px;
+	}
+	.hide {
+		padding: 2px 5px;
+	}
 }
 </style>