<template>
	<view class="">
		<uni-swipe-action ref="swipeAction">
			<uni-swipe-action-item :right-options="options" @click="swipeClicks($event)">
				<view class="uni-flex u-col-center space-between" style="
				background-color:#fff;
				margin-left: 10rpx;">
					<view class="card_partCode" >
						<view class="" >
							{{itemCode}}
						</view>
						<view class="">
							{{itemName}}
						</view>
					</view>
					<view class="" v-if="showCount">
						<count :countType="countType"
						:recommendQty="recommendQty" 
						:uom="uom" 
						:stdPackQty="stdPackQty"
						:handledQty="handledQty"></count>
					</view>
					
				</view>
			</uni-swipe-action-item>
		</uni-swipe-action>

	</view>

</template>

<script>
	export default {
		components: {
		},

		data() {
			return {
				options_edit: [{
					text: '编辑',
					style: {
						backgroundColor: '#F1A532'
					}
				}],
				options_clear: [{
					text: '清空',
					style: {
						backgroundColor: '#F56C6C'
					}
				}],
				options_remove: [{
					text: '移除',
					style: {
						backgroundColor: '#F56C6C'
					}
				}],
				options_all: [{
					text: '详情',
					style: {
						backgroundColor: '#3C9CFF'
					}
				},{
					text: '编辑',
					style: {
						backgroundColor: '#F1A532'
					}
				},
				{
					text: '移除',
					style: {
						backgroundColor: '#F56C6C'
					}
				}],
				index: 10,
				options: []
			}
		},
		props: {
			itemCode: {
				type: String,
				default: ''
			},
			itemName: {
				type: String,
				default: ''
			},
			itemDesc: {
				type: String,
				default: ''
			},
			recommendQty: {
				type: Number,
				default: 0
			},
			handledQty: {
				type: Number,
				default: 0
			},
			stdPackQty: {
				type: Number,
				default: 0,
			},
			uom: {
				type: String,
				default: ''
			},
			jobStatus: {
				type: Number,
				default: 0
			},
			actionType: {
				type: String,
				default: ''
			},
			countType: {
				type: String,
				default: 'recommend_handle_no_state'
			},
			showCount:{
				type:Boolean,
				default:true
			}
		},
		watch: {
			// recommend
			actionType: {
				handler(newval, oldval) {
					if (this.actionType == "edit") {
						this.options = this.options_edit;
					} else if(this.actionType == "clear"){
						this.options = this.options_clear;
					}else if(this.actionType == "remove"){
						this.options = this.options_remove;
					}else if(this.actionType == "all"){
						this.options = this.options_all;
					}
				},
				immediate: true,
				deep: true
			}
		},
		methods: {
			swipeClicks(e) {
				if (e.content.text == '详情') {
					this.$emit("detail")
				}else if (e.content.text == '编辑') {
					this.$emit("edit")
				} else if (e.content.text == '清空'|| e.content.text == '移除') {
					this.$emit("clear")
				}

			}
		}
	}
</script>

<style>
</style>
