AlanWong 2 rokov pred
rodič
commit
387ca8a5ac

+ 1 - 1
src/api/materialClass.ts

@@ -42,7 +42,7 @@ function classDelete(data : any) {
 // 根据父ID查询所有子节点列表
 function childrenTreeList(data : any) {
 	return request({
-		url: '/maindata/maindataMaterialCategory/childrenTreeList/id/'+data,
+		url: '/maindata/maindataMaterialCategory/childrenTreeList/id?id=' + data,
 		method: 'GET'
 	})
 }

+ 167 - 51
src/views/audit/brand/index.vue

@@ -1,15 +1,34 @@
 <template>
 	<div class="my-container">
-		<!-- 		<div class="bill-left">
-			<div class="bill-tab">
-				<div class="title">导航</div>
-				<el-tree :data="data" :props="props" @node-click="handleNodeClick"></el-tree>
-			</div>
-		</div> -->
 		<div class="bill-main">
 			<module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="getDataList"
-				@resert="getDataList" @clickHandle="clickHandle" />
+				@resert="getDataList" @clickHandle="clickHandle">
+				<template v-slot:status="{ value }">
+					<!-- <el-tag :type="value.row.status===0?'primary':'danger'"
+						disable-transitions>{{value.row.status===0?'正常':'禁用'}}</el-tag> -->
+						<div>{{value}}</div>
+				</template>
+			</module-view>
 		</div>
+		<!-- 新增/编辑弹窗 -->
+		<el-dialog :title="popTitle+'品牌'" :visible.sync="dialogFormVisible" width="30%">
+			<by-form :propConfig="addConfig" ref="addFormId">
+				<template v-slot:logo>
+					<el-upload :limit='1' :action="baseURL+'/file/upload'" list-type="picture-card"
+						:on-preview="handlePictureCardPreview" :on-remove="handleRemove">
+						<i class="el-icon-plus"></i>
+					</el-upload>
+				</template>
+				<template v-slot:status class="clearfix">
+					<el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="0">显示</el-radio>
+					<el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="1">禁用</el-radio>
+				</template>
+			</by-form>
+			<div slot="footer" class="dialog-footer">
+				<el-button @click="dialogFormVisible = false">取 消</el-button>
+				<el-button type="primary" @click="confirm">确 定</el-button>
+			</div>
+		</el-dialog>
 	</div>
 </template>
 <script lang="ts">
@@ -17,13 +36,12 @@
 	import api from "@/api/currency";
 	@Component
 	export default class Brand extends Vue {
+		baseURL : any = process.env.VUE_APP_BASE_API
 		timeNum = 0;
 		timer : any = null
-		data : any = []
-		props = {
-			label: 'name',
-			children: 'children'
-		}
+		popTitle : any = ''
+		radio : any = 0
+		dialogFormVisible : boolean = false
 		config : any = {
 			search: {
 				attr: {
@@ -85,7 +103,13 @@
 				]
 			},
 			tool: {
-				tools: this.getTools()
+				tools: {
+					add: true,
+					export: true,
+					delete: true,
+					search: true,
+					refresh: true
+				}
 			},
 			table: {
 				attr: {
@@ -104,29 +128,16 @@
 					field: 'shortName',
 					width: 100
 				}, {
-					title: '财务编号',
-					field: 'accountingCode'
-				}, {
-					title: '国际码',
-					field: 'nsCode'
-				}, {
-					title: '基本售价',
-					field: 'basePrice'
-				}, {
-					title: '市场价格(统一售价)',
-					field: 'markPrice'
+					title: '品牌logo',
+					field: 'logo'
 				}, {
-					title: '单位',
-					field: 'unit'
+					title: '状态',
+					field: 'status',
+					slot: true,
+					prop: 'status',
 				}, {
-					title: '重量',
-					field: 'weight'
-				}, {
-					title: '保质期(天)',
-					field: 'shelfLife'
-				}, {
-					title: '库存',
-					field: 'stock'
+					title: '备注',
+					field: 'remark'
 				}, {
 					title: '操作',
 					action: true,
@@ -136,32 +147,101 @@
 						audit: '',
 						event: {
 							click: (item : any) => {
-								console.log('该行数据:', item)
+								(this as any).openEdit(item)
 							}
 						}
 					}, {
 						name: '删除',
 						event: {
-							click: (item : any) => this.onDelete(item)
+							click: (item : any) => (this as any).doDelete2(item)
 						}
 					}]
 				}]
 			},
 		}
-		getTools() {
-			return {
-				add: true,
-				export: true,
-				delete: true,
-				search: true,
-				refresh: true
-			}
+		addConfig = {
+			attr: {
+				size: 'small',
+				rules: {
+					name: [{
+						required: true, message: '请输入名称', trigger: 'blur'
+					}],
+					shortName: [{
+						required: true, message: '请输入简称', trigger: 'blur'
+					}]
+				}
+			},
+			columns: [
+				[
+					{
+						span: 20,
+						label: '名称',
+						prop: 'name',
+						component: 'by-input',
+					},
+					{
+						span: 20,
+						label: '简称',
+						prop: 'shortName',
+						component: 'by-input',
+					},
+					{
+						span: 20,
+						label: '品牌logo',
+						slot: true,
+						prop: 'logo',
+					},
+					{
+						span: 20,
+						label: '显示状态',
+						slot: true,
+						prop: 'status',
+					},
+				],
+				[
+					{
+						span: 20,
+						label: '备注',
+						prop: 'remark',
+						component: 'by-input',
+					},
+				]
+			]
 		}
 		created() {
 			this.timer = setInterval(() => {
 				this.getDataList()
 			}, 500)
 		}
+		// 确认新增/编辑
+		confirm() {
+			(this as any).$refs.addFormId.validate().then(() => {
+				let query = (this as any).$refs.addFormId.getValue();
+				query.status = this.radio;
+				this.dialogFormVisible = false;
+				if (this.popTitle === '新增') {
+					api.saveList(query, 'maindataMaterialBrand').then((res : any) => {
+						if (res.code === 200) {
+							this.$message({
+								type: 'success',
+								message: this.popTitle + '成功!'
+							});
+							this.getDataList();
+						} else this.failHandle(res)
+					})
+				} else if (this.popTitle === '编辑') {
+					api.updateList(query, 'maindataMaterialBrand').then((res : any) => {
+						if (res.code === 200) {
+							this.$message({
+								type: 'success',
+								message: this.popTitle + '成功!'
+							});
+							this.getDataList();
+						} else this.failHandle(res)
+					})
+				}
+			})
+		}
 		// 获取列表数据
 		getDataList() {
 			if (!this.$refs.moduleView) {
@@ -187,19 +267,49 @@
 		}
 		// 工具栏方法
 		clickHandle(e : any) {
-			console.log(e);
 			if (e === 'onRefresh') (this.$refs.moduleView as any).resert();
 			if (e === 'onAdd') this.onAdd();
-			// if (e === 'onDelete') this.onDelete(e);
+			if (e === 'onDelete') this.onDelete();
 			if (e === 'onExport') this.onExport();
 		}
-		// 新增
+		// 打开新增
 		onAdd() {
-
-			(this as any).$router.push('/materialFile/detail')
+			this.popTitle = '新增'
+			this.dialogFormVisible = true;
+			setTimeout(() => {
+				if ((this as any).$refs.addFormId) (this as any).$refs.addFormId.setValue({});
+			}, 0)
 		}
-		// 删除
-		onDelete(item : any) {
+		// 打开编辑
+		openEdit(e : any) {
+			this.popTitle = '编辑'
+			this.dialogFormVisible = true;
+			setTimeout(() => {
+				if ((this as any).$refs.addFormId) (this as any).$refs.addFormId.setValue(e);
+			}, 0)
+		}
+		// 工具栏删除
+		onDelete() {
+			let selectData = (this.$refs.moduleView as any).getSelectData()
+			let ids = '';
+			if (selectData.length > 0) {
+				selectData.map((v : any) => {
+					ids += v.id + ','
+				})
+			} else return this.$message({ type: 'warning', message: '请选择删除数据' })
+			ids = ids.slice(0, ids.length - 1);
+			api.deleteList({ ids: ids }, 'maindataMaterialBrand').then((res : any) => {
+				if (res.code === 200) {
+					this.getDataList();
+					this.$message({
+						type: 'success',
+						message: '删除成功!'
+					});
+				} else this.failHandle(res)
+			})
+		}
+		// 操作删除
+		doDelete2(item : any) {
 			api.deleteList({ ids: item.id }, 'maindataMaterialBrand').then((res : any) => {
 				if (res.code === 200) {
 					this.getDataList();
@@ -210,6 +320,12 @@
 				} else this.failHandle(res)
 			})
 		}
+		handleRemove(file : any, fileList : any) {
+			console.log(file, fileList);
+		}
+		handlePictureCardPreview(file : any) {
+			console.log(file);
+		}
 		//导出
 		onExport() {
 			let urlArr = '/maindata/maindataMaterial';

+ 1 - 1
src/views/audit/materialAdd/index.vue

@@ -456,7 +456,7 @@
 				}
 			})
 		}
-
+		// 表单校验
 		getFormVali() {
 			(this as any).$refs.form.validate().then(() => {
 				console.log('验证通过')

+ 18 - 20
src/views/audit/productClassification/index.vue

@@ -8,7 +8,7 @@
 		</div>
 		<div class="bill-main">
 			<div v-show="!hideSearch">
-				<by-form :propConfig="config" ref="formId" />
+				<by-form :propConfig="formConfig" ref="formId" />
 				<div class="search-btn">
 					<el-button type="primary" size="mini" icon="el-icon-search" @click="searchHandle">搜索</el-button>
 					<el-button size="mini" icon="el-icon-refresh" @click="resertHandle">重置</el-button>
@@ -36,7 +36,7 @@
 			</el-table>
 			<!-- 新增/编辑弹窗 -->
 			<el-dialog :title="title+'分类'" :visible.sync="dialogFormVisible" width="30%">
-				<by-form :propConfig="addConfig" ref="addFormId" style="height:250px;">
+				<by-form :propConfig="addConfig" ref="addFormId">
 					<!-- 					<template v-slot:uploadImg>
 						<div class="upload-img">+</div>
 					</template> -->
@@ -91,10 +91,9 @@
 				export: 'audit:collaborationLog:export'
 			}
 		}
-		config = {
+		formConfig = {
 			attr: {
 				size: 'small',
-				height: 40
 			},
 			columns: [
 				[{
@@ -154,7 +153,14 @@
 		addConfig = {
 			attr: {
 				size: 'small',
-				height: 60
+				rules: {
+					name: [{
+						required: true, message: '请输入名称', trigger: 'blur'
+					}],
+					shortName: [{
+						required: true, message: '请输入简称', trigger: 'blur'
+					}]
+				}
 			},
 			columns: [
 				[
@@ -167,7 +173,7 @@
 					},
 					{
 						span: 20,
-						label: '分类名称',
+						label: '名称',
 						prop: 'name',
 						component: 'by-input',
 						labelWidth: '80px',
@@ -197,7 +203,7 @@
 		created() {
 			this.getDataList()
 		}
-		clickMy(e:any){
+		clickMy(e : any) {
 			console.log(e);
 		}
 		// 获取列表数据
@@ -237,9 +243,9 @@
 			this.title = '新增';
 			this.radio = '0';
 			this.cascaderValue = [0];
+			this.dialogFormVisible = true;
 			setTimeout(() => {
 				if ((this as any).$refs.addFormId) (this as any).$refs.addFormId.setValue({});
-				this.dialogFormVisible = true;
 			}, 0)
 		}
 		// 编辑
@@ -255,13 +261,9 @@
 		}
 		// 确认新增/编辑
 		confirm() {
-			let query = (this as any).$refs.addFormId.getValue();
-			let pareteId : any = this.cascaderValue[this.cascaderValue.length - 1];
-			if (pareteId !== 0) if (!this.cascaderValue[this.cascaderValue.length - 1]) return this.$message({
-				type: 'error',
-				message: '请输入完整字段'
-			})
-			if (query.name?.length > 0 && query.shortName?.length > 0 && query.remark?.length > 0) {
+			(this as any).$refs.addFormId.validate().then(() => {
+				let query = (this as any).$refs.addFormId.getValue();
+				let pareteId : any = this.cascaderValue[this.cascaderValue.length - 1];
 				// console.log(pareteId, this.radio);
 				this.dialogFormVisible = false;
 				if (this.title === '新增') {
@@ -298,10 +300,6 @@
 						} else this.failHandle(res)
 					})
 				}
-
-			} else this.$message({
-				type: 'error',
-				message: '请输入完整字段'
 			})
 		}
 
@@ -339,7 +337,7 @@
 		}
 		// 导航切换
 		handleNodeClick(e : any) {
-			console.log('导航切换id ==> ',e.id);
+			// console.log('导航切换id ==> ', e.id);
 			this.loading = true;
 			api.childrenTreeList(e.id).then((res : any) => {
 				if (res.code === 200) {

+ 7 - 3
src/views/audit/productManagement/index.vue

@@ -8,7 +8,7 @@
 		</div>
 		<div class="bill-main">
 			<module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="getDataList"
-				@resert="getDataList" @clickHandle="clickHandle" />
+				@resert="getDataList" @clickHandle="clickHandle" @detail="detail" />
 		</div>
 	</div>
 </template>
@@ -150,7 +150,8 @@
 				},
 				columns: [{
 					title: '名称',
-					field: 'name'
+					field: 'name',
+					isDetail:true,
 				}, {
 					title: '简称',
 					field: 'shortName'
@@ -198,7 +199,7 @@
 					}, {
 						name: '删除',
 						event: {
-							click: (item : any) => this.doDelete2(item)
+							click: (item : any) => (this as any).doDelete2(item)
 						}
 					}]
 				}]
@@ -219,6 +220,9 @@
 				this.getDataList()
 			}, 500)
 		}
+		detail(e:any){
+			console.log(e);
+		}
 		// 获取树型导航数据
 		getTreeList() {
 			materialClass.treeList().then((res : any) => {