<template>
	<ciy-header title="新增/编辑页" ref="header"></ciy-header>
	<view v-if="init.code != 1">
		<view class="px4 py4">
			<view style="height:2em;width:60%;" class="ciy-skeleton"></view>
			<view style="height:1em;width:40%;margin-left:1em;" class="ciy-skeleton"></view>
			<view style="height:1em;width:50%;" class="ciy-skeleton"></view>
			<view style="height:6em;width:100%;" class="ciy-skeleton"></view>
		</view>
	</view>
	<view v-else>
		<view class="ciy-form-group">
			<view class="ciy-form">
				<label class="imp">默认标题</label>
				<view>
					<ciy-input v-model="editdata.name"></ciy-input>
				</view>
			</view>
			<view class="ciy-form">
				<label>所属菜单</label>
				<view>
					<ciy-select :range="g.zc_menu" v-model="editdata.menuid"></ciy-select>
				</view>
			</view>
			<view class="ciy-form">
				<label>文件大小</label>
				<view>
					<ciy-inputbet bet="1024" unit="KB" v-model="editdata.filesize"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>长度</label>
				<view>
					<ciy-inputbet bet="1000" unit="米" :ciystyle="{width:'8em'}" v-model="editdata.metre"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>贷款金额</label>
				<view>
					<ciy-inputbet bet="1000000" unit="万元" v-model="editdata.bankmoney"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>设置日期</label>
				<view>
					<ciy-inputdatetime v-model="editdata.setdate"></ciy-inputdatetime>
				</view>
			</view>
			<view class="ciy-form">
				<label>设置时间</label>
				<view>
					<ciy-inputdatetime btime v-model="editdata.settimes"></ciy-inputdatetime>
				</view>
			</view>
			<view class="ciy-form">
				<label>营业时间</label>
				<view>
					<ciy-inputtimepoint bsec v-model="editdata.dayclock"></ciy-inputtimepoint>
				</view>
			</view>
			<view class="ciy-form">
				<label>文档</label>
				<view>
					<ciy-upload num="5" filetype="all" imgwidth="1000" sourcetype="album,message" path="demo" v-model="editdata.downurl"></ciy-upload>
				</view>
			</view>
			<view class="ciy-form">
				<label>头像</label>
				<view>
					<ciy-upload imgwidth="600" imgheight="600" path="demo" v-model="editdata.avar"></ciy-upload>
				</view>
			</view>
			<view class="ciy-form">
				<label>是否使用</label>
				<view>
					<ciy-selbool v-model="editdata.isuse"></ciy-selbool>
				</view>
			</view>
			<view class="ciy-form">
				<label>是否开启</label>
				<view>
					<ciy-selbool y="开启" n="关闭" v-model="editdata.isopen"></ciy-selbool>
				</view>
			</view>
			<view class="ciy-form">
				<label>库存单位</label>
				<view>
					<ciy-inputunitedit v-model="editdata.unit"></ciy-inputunitedit>
				</view>
			</view>
			<view class="ciy-form">
				<label>单选状态</label>
				<view>
					<ciy-radio left :range="g.auditstatus" v-model="editdata.sigstatus"></ciy-radio>
				</view>
			</view>
			<view class="ciy-form">
				<label>多选状态</label>
				<view>
					<ciy-checkbox itemright line :range="g.auditstatus" v-model="editdata.mauditstatus"></ciy-checkbox>
				</view>
			</view>
			<view class="ciy-form">
				<label>组织结构</label>
				<view>
					<ciy-selcas :range="g.zc_depart" v-model="editdata.prodcata"></ciy-selcas>
				</view>
			</view>
			<view class="ciy-form">
				<label>所在地区</label>
				<view>
					<ciy-selcas :range="g.ciy_arearpc" v-model="editdata.areacode"></ciy-selcas>
				</view>
			</view>
			<view class="ciy-form">
				<label>认证情况</label>
				<view>
					<ciy-checkbox bin left line :range="g.renzheng" v-model="editdata.renzheng"></ciy-checkbox>
				</view>
			</view>
			<view class="ciy-form">
				<label>临时字典</label>
				<view>
					<ciy-select :range="g.ppint" v-model="editdata.ppint"></ciy-select>
				</view>
			</view>
			<view class="ciy-form">
				<label>执行周期</label>
				<view>
					<ciy-inputcyc v-model="editdata.npcyc"></ciy-inputcyc>
				</view>
			</view>
			<view class="ciy-form">
				<label>执行用时</label>
				<view>
					<ciy-input v-model="editdata.runsec"></ciy-input>
				</view>
				<view style="flex:none;">秒</view>
			</view>
			<view class="ciy-form">
				<label>活动期数</label>
				<view class="flex flex-center" style="justify-content: flex-end;">
					第
					<ciy-input :ciystyle="{width:'3em',margin:'0 0.5em',textAlign:'center',display:'inline-block'}" v-model="editdata.acttm"></ciy-input>
					期
				</view>
			</view>
			<view class="ciy-form">
				<label>活动花絮</label>
				<view>
					<ciy-upload num="9" imgwidth="1920" zipjpg="80" path="demo" v-model="editdata.imgs"></ciy-upload>
				</view>
			</view>
			<view class="ciy-form">
				<label>吨位</label>
				<view>
					<ciy-inputbet bb bet="1000000" unit="吨" :ciystyle="{width:'8em'}" v-model="editdata.ton"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>单价</label>
				<view>
					<ciy-inputbet bet="100" unit="元" v-model="editdata.price"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>位置</label>
				<view>
					<ciy-selmap v-model:lng="editdata.lng" v-model:lat="editdata.lat"></ciy-selmap>
				</view>
			</view>
			<view class="ciy-form">
				<label>百分比</label>
				<view>
					<ciy-inputbet bet="100" unit="%" v-model="editdata.pct"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>链接</label>
				<view>
					<ciy-input v-model="editdata.url"></ciy-input>
				</view>
			</view>
			<view class="ciy-form">
				<label>体重</label>
				<view>
					<ciy-inputbet bet="1000" unit="公斤" v-model="editdata.weightg"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>耳温</label>
				<view>
					<ciy-inputbet bet="1000" unit="℃" v-model="editdata.eartmpr"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>身份证号</label>
				<view>
					<ciy-input v-model="editdata.idcard"></ciy-input>
				</view>
			</view>
			<view class="ciy-form">
				<label>介绍</label>
				<view>
					<ciy-textarea v-model="editdata.content"></ciy-textarea>
				</view>
			</view>
			<!-- <view class="ciy-form v">
				<label>富文本</label>
				<view>
					<ciy-mdedit v-model="editdata.md"></ciy-mdedit>
				</view>
			</view> -->
		</view>

		<view class="tabbar ciy-bottom">
			<button class="btn lg cc long" @tap="edited">{{lang('page.btn_submit')}}</button>
		</view>
	</view>
</template>

<style>
</style>

<script>
	export default {
		props: ['id'],
		data() {
			return {}
		},
		onLoad() {
			console.log(this.pagedata); //gourl函数可带出来该行数据
			this.getdata();
		},
		watch: {},
		computed: {},
		methods: {
			async getdata() {
				if (this._loading)
					return;
				this._loading = true;
				var retjson = await this.callfunc({
					func: 'demo/demo.getdata',
					//data: this.opn  //callfunc会自动带上opn数据
				});
				this._loading = false;
				if (retjson.code != 1)
					return this.init = retjson;
				this.g.zc_menu = retjson.zc_menu;		//因列表增量加载，需要全量获取列表字典
				// this.g.ppint = retjson.ppint;		//字典从列表全量获得，如果为从列表进入，则需后台获取
				// this.g.renzheng = retjson.renzheng;	//字典从列表全量获得，如果为从列表进入，则需后台获取
				this.editdata = retjson.data;
				this.init = this.objdeepmerge(this.init, retjson);
			},
			async edited() {
				if (this._loading)
					return;
				this._loading = true;
				var retjson = await this.callfunc({
					func: 'demo/demo.update',
					data: this.editdata
				});
				this._loading = false;
				if (retjson.code != 1)
					return this.alert(retjson.errmsg);
				var page = getApp().getpage(1);
				if (page?.init?.list)
					this.objtolist(page.init.list, retjson.data);
				await this.toast('提交成功');
				// const eventChannel = this.getOpenerEventChannel();
				// eventChannel.emit('writedata', retjson.data);
				uni.navigateBack();
			}
		}
	}
</script>