shish 1 год назад
Родитель
Сommit
924210be66
3 измененных файлов с 130 добавлено и 11 удалено
  1. 2 0
      ghs/src/cool/request/index.js
  2. 14 0
      ghs/src/service/live-order/index.js
  3. 114 11
      ghs/src/views/order/add-live.vue

+ 2 - 0
ghs/src/cool/request/index.js

@@ -72,12 +72,14 @@ import cgRefund from '@/service/cg-refund/index';
 import clear from '@/service/clear/index';
 import refund from '@/service/refund/index';
 import costChange from '@/service/cost-change/index';
+import liveOrder from '@/service/live-order/index';
 
 export function SET_SERVICE({ store }) {
 	// const files = require.context('@/service/', true, /\.js$/);
 	// const ignore = ['./request.js'];
 
 	let modules = {
+		liveOrder,
 		costChange,
 		refund,
 		clear,

+ 14 - 0
ghs/src/service/live-order/index.js

@@ -0,0 +1,14 @@
+import { BaseService, Service } from '@/cool';
+@Service('live-order')
+export class LiveOrderService extends BaseService {
+
+	addOrder(data) {
+		return this.request({
+			url: '/add-order',
+			method: 'POST',
+			data: data
+		});
+	}
+
+}
+export default new LiveOrderService();

+ 114 - 11
ghs/src/views/order/add-live.vue

@@ -3,19 +3,46 @@
 
 		<div>
 			<el-select @change="getCurrentItem" v-model="currentItemName" filterable remote reserve-keyword placeholder="搜索花材" clearable ref="itemSearchRef"
-			:remote-method="searchItem" style="width:300px;margin-left:30px;margin-top:30px;">
-				<el-option v-for="item in itemList" :key="item.id" :label="`${item.name}(${item.id})`" :value="item.id"> </el-option>
+			:remote-method="searchItem" style="width:260px;margin-left:30px;margin-top:15px;">
+				<el-option v-for="item in itemList" :key="item.id" :label="`${item.name}(${item.id})`" :value="item"> </el-option>
 			</el-select>
-			<el-input v-model="price" placeholder="请输入价格" style="width:200px;margin-left:10px;"></el-input>
+			<el-input v-model="price" placeholder="请输入价格" style="width:130px;margin-left:10px;"></el-input>
 		</div>
 
 		<div>
 			<el-select @change="getCurrentCustom" v-model="currentCustomName" filterable remote reserve-keyword placeholder="搜索客户" clearable ref="customSearchRef"
-			:remote-method="searchCustom" style="width:300px;margin-left:30px;margin-top:30px;">
+			:remote-method="searchCustom" style="width:260px;margin-left:30px;margin-top:15px;">
 				<el-option v-for="item in customList" :key="item.id" :label="`${item.name}(${item.id})`" :value="item"> </el-option>
 			</el-select>
 		</div>
+		<div style="margin-left:30px;margin-top:15px;" class="custom-data">
+			<el-table ref="showItemRef" :data="selectCustomList" highlight-current-row border>
+				<el-table-column prop="customId" label="ID" align="center" width="100"></el-table-column>
+				<el-table-column prop="customName" label="名称" align="center" width="200"></el-table-column>
 
+				<el-table-column prop="num" label="数量" align="center" width="130">
+					<template slot-scope="scope">
+						<el-input v-model="scope.row.num" placeholder="数量"></el-input>
+					</template>
+				</el-table-column>
+
+				<el-table-column prop="price" label="价格" align="center" width="130">
+					<template slot-scope="scope">
+						<el-input v-model="scope.row.price" placeholder="价格"></el-input>
+					</template>
+				</el-table-column>
+
+				<el-table-column prop="operate" label="操作" align="center" width="230">
+					<template slot-scope="scope">
+						<el-button type="primary" @click="del(scope.row.customId)">删除</el-button>
+					</template>
+				</el-table-column>
+
+			</el-table>
+		</div>
+		<div style="margin-top:30px;">
+			<el-button type="primary" style="margin-left:300px;" @click="commit()">提交</el-button>
+		</div>
 	</div>
 </template>
 <script>
@@ -30,8 +57,9 @@ export default {
 			itemList: [],
 			customList:[],
 			price:'',
+			currentItemId:0,
 			currentCustomName:'',
-			selectCustomList:[],
+			selectCustomList:[]
 		};
 	},
 	computed: {
@@ -45,16 +73,85 @@ export default {
 	},
 	methods: {
 		...mapActions(['getLevel']),
-		getCurrentCustom(e){
+		commit(){
 			let that = this
-			console.log(e)
-			this.currentCustomName = ''
-			this.$nextTick(() => {
-				//this.$refs.customSearchRef.focus()
+			if(Number(this.currentItemId)<=0){
+				this.$message.error('请选花材');
+				return false
+			}
+			if (this.$util.isEmpty(this.selectCustomList)) {
+				this.$message.error('请选客户');
+				return false
+			}
+			let hasError = false
+			let errorMsg = ''
+			this.selectCustomList.forEach((item,idx,arr) => {
+				if(Number(item.num)<=0){
+					hasError = true
+					errorMsg = item.customName+' 数量没有填写'
+					return
+				}
+				if(Number(item.price)<=0){
+					hasError = true
+					errorMsg = item.customName+' 价格没有填写'
+					return
+				}
+			})
+			if(hasError == true){
+				this.$message.error(errorMsg);
+				return false
+			}
+			let json  = JSON.stringify(this.selectCustomList)
+			let params = {selectCustom:json,itemId:this.currentItemId}
+			this.$confirm('确认提交', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => {
+				that.$service.liveOrder.addOrder(params).then(data => {
+					this.$message.success('添加成功')
+					setTimeout(() => {
+						that.clearData()
+					}, 1000);
+				})
 			})
 		},
+		clearData(){
+			this.currentItemName = ''
+			this.itemList = []
+			this.customList = []
+			this.price = ''
+			this.currentItemId = 0
+			this.currentCustomName = ''
+			this.selectCustomList = []
+		},
+		del(customId){
+			if (!this.$util.isEmpty(this.selectCustomList)) {
+				let index = -1
+				this.selectCustomList.forEach((item,idx,arr) => {
+					if(Number(item.customId) == Number(customId)){
+						index = idx
+					}
+				})
+				if(index > -1){
+					this.selectCustomList.splice(index,1)
+				}
+			}
+		},
+		getCurrentCustom(e){
+			this.currentCustomName = ''
+			let has = false
+			if (this.$util.isEmpty(this.selectCustomList)) {
+				
+			}else{
+				this.selectCustomList.forEach((item,idx,arr) => {
+					if(Number(item.customId) == Number(e.id)){
+						has = true
+					}
+				})
+			}
+			if(has == false){
+				this.selectCustomList.unshift({customId:e.id,customName:e.name,num:'',price:this.price,operate:''})
+			}
+		},
 		getCurrentItem(e){
-			console.log(e)
+			this.currentItemId = e.id
 		},
 		searchItem(query) {
 			let that = this
@@ -85,5 +182,11 @@ export default {
 <style lang="scss" scoped>
 .app-list-content{
 	background-color: white;
+	.custom-data{
+		::v-deep .el-input__inner {
+			padding:0;
+			text-align:center;
+		}
+	}
 }
 </style>