<template>
	<view>
		<view class="address" @click="address()">
			<view class="con">
				<view class="title omit">云南省普洱市思茅区普洱路云南省普洱市思茅区普洱路36号云南省普洱市思茅区普洱路云南省普洱市思茅区普洱路</view>
				<view class="desc">
					<text>陈晓东</text>
					<text>13481076556</text>
				</view>
			</view>
			<view class="icon">&#xe8f2;</view>
			<view class="clear"></view>
		</view>
		<view class="forms">
			<view class="form_group">
				<view class="lable re">互市区</view>
				<picker :range="dict.city" @change="picker($event, 'city')">
					<input placeholder="请选择" v-model="item.city" :disabled="true" />
					<view class="icon more">&#xe8f2;</view>
				</picker>
			</view>
			<view class="form_group">
				<view class="lable re">收购商品</view>
				<picker :range="dict.city" @change="picker($event, 'city')">
					<input placeholder="请选择" v-model="item.city" :disabled="true" />
					<view class="icon more">&#xe8f2;</view>
				</picker>
			</view>
			<view class="form_group">
				<view class="lable">商品编号</view>
				<input placeholder="请输入" v-model="item.typeCode" />
			</view>
			<view class="form_group">
				<view class="lable re">计价单位</view>
				<picker :range="dict.city" @change="picker($event, 'city')">
					<input placeholder="请选择" v-model="item.city" :disabled="true" />
					<view class="icon more">&#xe8f2;</view>
				</picker>
			</view>
			<view class="form_group">
				<view class="lable re">数量</view>
				<input placeholder="请输入" v-model="item.typeCode" />
			</view>
			<view class="form_group">
				<view class="lable re">到货日期</view>
				<picker mode="date" @change="picker($event, 'date')">
					<input placeholder="请选择" v-model="item.date" :disabled="true" />
					<view class="icon more">&#xe8f2;</view>
				</picker>
			</view>
		</view>
		<view class="mfooter">
			<view class="flex">
				<view class="f">
					<button class="save btn" @click="save()">保存</button>
				</view>
				<view class="f">
					<button class="btn" @click="save()">一键发布</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			item: {},
			dict: {
				city: ['东兴市', '贵港市']
			}
		};
	},
	onLoad(e) {
		if (e.id) {
			this.http.request({
				url: '/level-one-server/app/TbPortNews/getPortNewsDetails',
				data: { id: e.id },
				success: res => {
					this.item = res.data.data;
				}
			});
		}
		uni.$on('selectAddress', res => {});
	},
	methods: {
		//选择地址
		address() {
			uni.navigateTo({ url: '/pages/market/two/purchaser/address/list?select=true' });
		},
		picker(e, tag) {
			if (tag == 'date') {
				this.item[tag] = e.detail.value;
			} else {
				this.item[tag] = this.dict[tag][e.detail.value];
			}
			this.$forceUpdate();
		},
		save() {
			/* let rule = [
				{ name: 'typeCode', checkType: 'notnull', errorMsg: '请输入编码' },
				{ name: 'typeName', checkType: 'notnull', errorMsg: '请输入名称' },
				{ name: 'status', checkType: 'notnull', errorMsg: '请选择状态' }
			];
			if (!this.verify.check(this.item, rule)) {
				uni.showModal({ content: this.verify.error, showCancel: false });
				return false;
			}
			this.http.request({
				url: '/project/projectType',
				method: 'POST',
				data: this.item,
				success: res => {
					uni.showToast({ title: '操作成功' });
					setTimeout(() => {
						uni.$emit('purchaser_buy_list');
						uni.navigateBack();
					}, 1000);
				}
			}); */
		}
	}
};
</script>

<style lang="scss">
.address {
	border-bottom: 1px solid $line;
}
.btn {
	width: 100%;
	border-radius: 5px;
}
</style>
