shish 4 lat temu
rodzic
commit
63cc5c0f67

+ 5 - 0
hdPad/src/api/work/index.js

@@ -21,4 +21,9 @@ export const lockWork = data => {
 
 export const cancelWork = data => {
 	return https.get('/work/cancel', data)
+}
+
+//创建工单 ssh 20220426
+export const createWorkFn = data => {
+	return https.post('/work/create', data)
 }

+ 101 - 23
hdPad/src/pages/home/components/finishWork.vue → hdPad/src/pages/home/components/createWork.vue

@@ -5,9 +5,7 @@
           <view class="item">
             <text class="left">分类</text>
             <view class="class-item-list">
-                <view>花束</view>
-                <view>花盒</view>
-                <view>盆栽</view>
+                <view v-for="info in catList" :class="[form.catId===info.id?'selected':'']" @click="setCat(info)" :key="info.id">{{info.categoryName}}</view>
             </view>
           </view>
           <view class="item">
@@ -19,21 +17,27 @@
           <view class="item">
             <text class="left">图片</text>
             <view>
-                
-          <htz-image-upload :max="1" :compress="true" v-model="currentImgData" :headers="headers"
-           @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
-          </htz-image-upload>
+
+                <htz-image-upload :max="1" :compress="true" v-model="currentImgData" :headers="headers"
+                @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
+                </htz-image-upload>
 
             </view>
           </view>
           <view class="item">
               <text class="left">打印</text>
-              <switch :checked="print == 1 ? true : false" @change="changePrint" style="transform: scale(0.9,0.8)" />
+              <switch :checked="form.needPrint == 1 ? true : false" @change="changePrint" style="transform: scale(0.9,0.8)" />
+          </view>
+
+          <view class="item">
+              <text class="left">直接完成</text>
+              <switch :checked="form.complete == 1 ? true : false" @change="changeComplete" style="transform: scale(0.9,0.8)" />
           </view>
+
         </view>
         <view class="footer">
-            <button @click="cancelFinish()">取消</button>
-            <button @click="confirmFinish()">确认</button>
+            <button @click="cancelCreate()">取消</button>
+            <button @click="confirmCreate()">确认</button>
         </view>
     </view>
 </template>
@@ -41,23 +45,31 @@
 //图片上传插件来源:https://ext.dcloud.net.cn/plugin?id=2922 已改造,不能再升级 shish 20211228
 import htzImageUpload from './htz-image-upload/htz-image-upload.vue'
 import { mapGetters } from "vuex"
+import {getClass} from '@/api/category'
+import productMins from "@/mixins/product"
+import { createWorkFn } from '@/api/work'
 export default {
     name:'finishWork',
     components:{
         htzImageUpload
     },
+    mixins: [productMins],
     data(){
         return {
-            print:1,
             flowerNumList:[{num:0,name:'无'},{num:6,name:6},{num:9,name:9},{num:11,name:11},{num:19,name:19},{num:33,name:33},{num:52,name:52},{num:66,name:66},{num:99,name:99}],
+            catList:[],
             form:{
                 name:'',
                 catId:0,
                 flowerNum:0,
                 cover:'',
-                print:0
+                needPrint:1,
+                complete:1
             },
-            headers:{token:''}
+            headers:{token:''},
+            currentImgData:[],
+            currentJobType:'make',
+            currentJobId:0,
         }
     },
 	computed:{
@@ -66,22 +78,83 @@ export default {
     mounted(){
         const token = uni.getStorageSync('token')
         this.headers.token = token
+        getClass({flower:1}).then(res=>{
+            if(res.code == 1){
+                this.catList = res.data
+                if(!this.$util.isEmpty(this.catList)){
+                    this.form.catId = this.catList[0].id
+                }
+            }
+        })
     },
     methods:{
+        imgUploadSuccess(res) {
+            var _res = JSON.parse(res.data)
+            if(_res.code == 1){
+                this.currentImgData.push(_res.data.smallUrl)
+                this.form.cover = _res.data.shortUrl
+            }
+        },
+        imgDeleteFn(res){
+            this.form.cover = ''
+        },
         setNum(info){
             this.form.flowerNum = info.num
         },
-        changePrint(){
-
+        setCat(info){
+            this.form.catId = info.id
         },
-        cancelFinish(){
-            this.$emit('cancelFinish')
+        changePrint(e){
+            if(e.detail.value == true){
+                this.form.needPrint = 1
+            }else{
+                this.form.needPrint = 2
+            }
+        },
+        changeComplete(e){
+            if(e.detail.value == true){
+                this.form.complete = 1
+            }else{
+                this.form.complete = 0
+            }
         },
-        confirmFinish(){
-            this.$emit('confirmFinish',this.form)
+        cancelCreate(){
+            this.$emit('cancelCreate')
+        },
+        confirmCreate(){
+            this.$util.hitRemind()
+            if(this.$util.isEmpty(this.form.name)){
+                this.$msg('请填写名称')
+                return false
+            }
+            if(this.form.cover == ''){
+                this.$msg('请上传图片')
+                return false
+            }
+			if(this.$util.isEmpty(this.selectList)){
+				this.$msg('请选择花材')
+				return false
+			}
+			let product = this.selectList.map(i=>({ productId:i.id, unitType: i.unitType, num: i.currentNum}))
+			uni.showLoading({mask:true})
+			createWorkFn({...this.form,product:JSON.stringify(product)}).then(res=>{
+				uni.hideLoading()
+				if(res.code == 1){
+					this.$msg(res.msg)
+                    this.$emit('confirmCreate')
+					this.removeFromSaveDirect()
+
+                    this.form.cover = ''
+                    this.currentImgData = []
+                    this.form.name=''
+                    this.form.catId = this.catList[0].id
+                    this.form.flowerNum = 0
+                    this.form.needPrint = 1
+                    this.form.complete = 1
+
+				}
+			})
         }
-    },
-    watch:{
     }
 }
 </script>
@@ -116,7 +189,7 @@ export default {
             width:150upx;
             flex-wrap:wrap;
             display:flex;
-            justify-content:space-between;
+            justify-content:center;
             margin:5upx 0 5upx 0;
             view{
                 width:30upx;
@@ -127,7 +200,12 @@ export default {
                 display: flex;
                 justify-content:center;
                 align-items:center;
-            }    
+                margin-left:3upx;
+            }
+            .selected{
+                background-color:#CCCCCC;
+                color:white;
+            } 
         }
         .flower-num-list{
             width:150upx;

+ 22 - 21
hdPad/src/pages/home/components/htz-image-upload/htz-image-upload.vue

@@ -136,11 +136,6 @@
 			let that = this
 			this.$nextTick(function() {
 				this.uploadLists = this.value;
-				if (this.mediaTypeData.indexOf(this.mediaType) == -1) {
-					that.$util.confirmModal({content:'mediaType参数不正确'},() => {
-						//console.log('用户点击确定');
-					})
-				}
 			});
 		},
 		watch: {
@@ -161,18 +156,24 @@
 			},
 			imgDel(index) {
 				let that = this
-				that.$util.confirmModal({content:'确认删除?'},() => {
-					// that.uploadLists.splice(index, 1)
-					// that.$emit("input", that.uploadLists);
-					// that.$emit("imgDelete", that.uploadLists);
-					let delUrl = that.uploadLists[index]
-					that.uploadLists.splice(index, 1)
-					that.$emit("input", that.uploadLists);
-					that.$emit("imgDelete", {
-						del: delUrl,
-						tempFilePaths: that.uploadLists,
-						index:index
-					});					
+				uni.showModal({
+					title: '提示',
+					content: '确认删除',
+					success: function (res) {
+						if (res.confirm) {
+									// that.uploadLists.splice(index, 1)
+									// that.$emit("input", that.uploadLists);
+									// that.$emit("imgDelete", that.uploadLists);
+									let delUrl = that.uploadLists[index]
+									that.uploadLists.splice(index, 1)
+									that.$emit("input", that.uploadLists);
+									that.$emit("imgDelete", {
+										del: delUrl,
+										tempFilePaths: that.uploadLists,
+										index:index
+									});	
+						}
+					}
 				})
 			},
 			imgPreview(index) {
@@ -607,11 +608,11 @@
 
 	.htz-image-upload-Item-del {
 		background-color: #f5222d;
-		font-size: 24upx;
+		font-size: 11upx;
 		position: absolute;
-		width: 35upx;
-		height: 35upx;
-		line-height: 35upx;
+		width: 15upx;
+		height: 15upx;
+		line-height: 15upx;
 		text-align: center;
 		top: 0;
 		right: 0;

+ 22 - 18
hdPad/src/pages/home/make.vue

@@ -21,8 +21,13 @@
             </view>
 
 			<!-- 完成工单弹框 -->
-			<uni-popup ref="finishWorkRef" background-color="#fff" type="right">
-				<finishWork @confirmCommit="confirmCommit" @cancelFinish="cancelFinish()"></finishWork>
+			<uni-popup ref="createWorkRef" background-color="#fff" type="right">
+				<createWork @cancelCreate="cancelCreate()" @confirmCreate="confirmCreate()"></createWork>
+			</uni-popup>
+
+			<!-- 清空 -->
+			<uni-popup ref="clearItemRef" type="dialog">
+				<uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="提示" content="确认清空?" @confirm="confirmClearItem"></uni-popup-dialog>
 			</uni-popup>
 
         </view>
@@ -34,11 +39,10 @@ import rightItem from './components/rightItem.vue'
 import leftItem from './components/leftArea.vue'
 import casherNav from './components/nav.vue'
 import productMins from "@/mixins/product"
-import { finish } from '@/api/work'
-import finishWork from './components/finishWork.vue'
+import createWork from './components/createWork.vue'
 export default {
 	name: "make",
-	components: { rightItem,leftItem, casherNav,finishWork},
+	components: { rightItem,leftItem, casherNav,createWork},
 	mixins: [productMins],
 	data() {
 		return {
@@ -84,24 +88,24 @@ export default {
 		}
 	},
 	methods: {
-		cancelFinish(){
-			this.$refs.finishWorkRef.close()
+		cancelCreate(){
+			this.$refs.createWorkRef.close()
+		},
+		confirmCreate(){
+			this.$refs.createWorkRef.close()
 		},
 		commit(){
 				this.$util.hitRemind()
-				this.$refs.finishWorkRef.open()
-		},
-		confirmCommit(form){
-			this.$refs.finishWorkRef.close()
-			finish({...form,id:this.orderInfo.id}).then(res=>{
-				if(res.code == 1){
-				this.$msg(res.msg)
-				this.getOrderDetail(this.orderInfo.id)
-				}
-			})
+				this.$refs.createWorkRef.open()
 		},
 		clearItemFn(){
-
+			this.$util.hitRemind()
+			this.$refs.clearItemRef.open()
+		},
+		//确认清空花材
+		confirmClearItem(){
+			this.$util.hitRemind()
+			this.removeFromSaveDirect()
 		},
 		changeProperty(property){
 			this.currentProperty = property