Browse Source

修改bug

chenrui 2 năm trước cách đây
mục cha
commit
9712efe4cb
1 tập tin đã thay đổi với 38 bổ sung51 xóa
  1. 38 51
      components/customPicker/checkBoxPicker.vue

+ 38 - 51
components/customPicker/checkBoxPicker.vue

@@ -3,9 +3,10 @@
 		<u-popup v-model="isShow" @close="isShow = false" mode="bottom" safe-area-inset-bottom border-radius="20">
 			<view class="content flex flex_column">
 				<view class="con">
-					<view class="choose-list u-flex u-row-between" v-for="(item, i) in list" :key="item.id" @click="getChooseItem(i)">
+					<view class="choose-list u-flex u-row-between" v-for="(item, i) in list" :key="item.id">
 						<view>{{ item.dispName }}</view>
-						<u-icon v-show="item.isChecked" name="checkbox-mark" color="#2979ff" size="28"></u-icon>
+						<!-- <u-icon v-show="item.isChecked" name="checkbox-mark" color="#2979ff" size="28"></u-icon> -->
+						<u-checkbox v-model="item.checked" :name="item.code" @change="getChooseItem" size="36"></u-checkbox>
 					</view>
 				</view>
 				<view class="btn u-flex">
@@ -32,6 +33,10 @@ export default {
 		val: {
 			type: String,
 			default: ''
+		},
+		filtrate:{
+			type: Boolean,
+			default: false
 		}
 	},
 	data() {
@@ -44,68 +49,47 @@ export default {
 	},
 	methods: {
 		getList() {
-			if (this.code == 'SALES_BILL_STATUS') {
-				var newList = [
-					{ id: 1099, isChecked: false, code: 'WAIT_SUBMIT', dispName: '待提交' },
-					{ id: 1100, isChecked: false, code: 'WAIT_AUDIT', dispName: '待审核' },
-					{ id: 1102, isChecked: false, code: 'WAIT_OUT_WAREHOUSE', dispName: '待出库' },
-					{ id: 1103, isChecked: false, code: 'FINISH', dispName: '已完结' }
-				];
-				if (this.val) {
-					//勾选上次选中值
-					let valArr = this.val.split(',');
-					newList.forEach(con => {
-						valArr.forEach(item => {
-							if (con.code == item) {
-								con.isChecked = true;
-							} else {
-								con.isChecked = false;
+			getLookUpDatas({
+				lookupCode: this.code,
+				pageNo: 1,
+				pageSize: 1000
+			}).then(result => {
+				if (result && result.status == 200) {
+					if(this.filtrate){//筛选业务状态
+						var selfArr=['WAIT_SUBMIT','WAIT_AUDIT','WAIT_OUT_WAREHOUSE','FINISH']
+						result.data.list=result.data.list.filter((item,i)=>{
+							if(selfArr.includes(item.code)){
+								return item
 							}
+						})
+						result.data.list.splice()
+					}
+					if (this.val) {//勾选上次选中值
+						var valArr = this.val.split(',');
+						result.data.list.forEach(value => {
+						valArr.includes(value.code) ? value.checked=true:value.checked=false
 						});
-					});
-				}
-				this.list = newList;
-			} else {
-				getLookUpDatas({
-					lookupCode: this.code,
-					pageNo: 1,
-					pageSize: 1000
-				}).then(result => {
-					if (result && result.status == 200) {
-						if (this.val) {
-							//勾选上次选中值
-							let valArr = this.val.split(',');
-							result.data.list.forEach(con => {
-								valArr.forEach(item => {
-									if (con.code == item) {
-										con.isChecked = true;
-									} else {
-										con.isChecked = false;
-									}
-								});
-							});
-						} else {
-							result.data.list.forEach(con => {
-								con.isChecked = false;
-							});
-						}
-						this.list = result.data.list;
 					}
-				});
-			}
+					this.list = result.data.list;
+				}
+			});
 		},
 		submit(index) {
 			let arr = [];
 			this.list.forEach(con => {
-				if (con.isChecked) {
+				if (con.checked) {
 					arr.push(con);
 				}
 			});
 			this.$emit('chooseCon', arr);
 			this.isShow = false;
 		},
-		getChooseItem(index) {
-			this.list[index].isChecked = !this.list[index].isChecked;
+		getChooseItem(e) {
+			const row = this.list.find(item => item.code == e.name)
+			if(row){
+				row.checked = !row.checked
+				this.list.splice()
+			}
 		}
 	},
 	watch: {
@@ -139,6 +123,9 @@ export default {
 			&:last-child {
 				border-bottom: 0rpx solid #efefef;
 			}
+			.u-checkbox{
+				display: inline-block !important;
+			}
 		}
 	}
 	.btn {