<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">
			<input type="hidden" name="id" :value="pagedata.demo.id" style="display:none;" />
			<view class="ciy-form">
				<label class="imp">默认标题</label>
				<view>
					<ciy-input name="name" v-model="pagedata.demo.name"></ciy-input>
				</view>
			</view>
			<view class="ciy-form">
				<label>所属菜单</label>
				<view>
					<ciy-select :range="g.zc_menu" name="menuid" v-model="pagedata.demo.menuid"></ciy-select>
				</view>
			</view>
			<view class="ciy-form">
				<label>文件大小</label>
				<view>
					<ciy-inputbet bet="1024" unit="KB" name="filesize" v-model="pagedata.demo.filesize"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>长度</label>
				<view>
					<ciy-inputbet bet="1000" unit="米" :ciystyle="{width:'8em'}" name="metre" v-model="pagedata.demo.metre"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>贷款金额</label>
				<view>
					<ciy-inputbet bet="1000000" unit="万元" name="bankmoney" v-model="pagedata.demo.bankmoney"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>设置日期</label>
				<view>
					<ciy-inputdatetime name="setdate" v-model="pagedata.demo.setdate"></ciy-inputdatetime>
				</view>
			</view>
			<view class="ciy-form">
				<label>设置时间</label>
				<view>
					<ciy-inputdatetime btime name="settimes" v-model="pagedata.demo.settimes"></ciy-inputdatetime>
				</view>
			</view>
			<view class="ciy-form">
				<label>营业时间</label>
				<view>
					<ciy-inputtimepoint bsec name="dayclock" v-model="pagedata.demo.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" name="downurl" v-model="pagedata.demo.downurl"></ciy-upload>
				</view>
			</view>
			<view class="ciy-form">
				<label>头像</label>
				<view>
					<ciy-upload imgwidth="600" imgheight="600" path="demo" name="avar" v-model="pagedata.demo.avar"></ciy-upload>
				</view>
			</view>
			<view class="ciy-form">
				<label>是否使用</label>
				<view>
					<ciy-selbool name="isuse" v-model="pagedata.demo.isuse"></ciy-selbool>
				</view>
			</view>
			<view class="ciy-form">
				<label>是否开启</label>
				<view>
					<ciy-selbool y="开启" n="关闭" name="isopen" v-model="pagedata.demo.isopen"></ciy-selbool>
				</view>
			</view>
			<view class="ciy-form">
				<label>库存单位</label>
				<view>
					<ciy-inputunitedit name="unit" v-model="pagedata.demo.unit"></ciy-inputunitedit>
				</view>
			</view>
			<view class="ciy-form">
				<label>单选状态</label>
				<view>
					<ciy-radio left :range="g.auditstatus" name="sigstatus" v-model="pagedata.demo.sigstatus"></ciy-radio>
				</view>
			</view>
			<view class="ciy-form">
				<label>多选状态</label>
				<view>
					<ciy-checkbox itemright line :range="g.auditstatus" name="mauditstatus" v-model="pagedata.demo.mauditstatus"></ciy-checkbox>
				</view>
			</view>
			<view class="ciy-form">
				<label>组织结构</label>
				<view>
					<ciy-selcas :range="g.zc_depart" name="prodcata" v-model="pagedata.demo.prodcata"></ciy-selcas>
				</view>
			</view>
			<view class="ciy-form">
				<label>所在地区</label>
				<view>
					<ciy-selcas :range="g.ciy_arearpc" name="areacode" v-model="pagedata.demo.areacode"></ciy-selcas>
				</view>
			</view>
			<view class="ciy-form">
				<label>认证情况</label>
				<view>
					<ciy-checkbox bin left line :range="g.renzheng" name="renzheng" v-model="pagedata.demo.renzheng"></ciy-checkbox>
				</view>
			</view>
			<view class="ciy-form">
				<label>临时字典</label>
				<view>
					<ciy-select :range="g.ppint" name="ppint" v-model="pagedata.demo.ppint"></ciy-select>
				</view>
			</view>
			<view class="ciy-form">
				<label>执行周期</label>
				<view>
					<ciy-inputcyc name="npcyc" v-model="pagedata.demo.npcyc"></ciy-inputcyc>
				</view>
			</view>
			<view class="ciy-form">
				<label>执行用时</label>
				<view>
					<ciy-input name="runsec" v-model="pagedata.demo.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'}" name="acttm" v-model="pagedata.demo.acttm"></ciy-input>
					期
				</view>
			</view>
			<view class="ciy-form">
				<label>活动花絮</label>
				<view>
					<ciy-upload num="9" imgwidth="1920" zipjpg="0.8" path="demo" name="imgs" v-model="pagedata.demo.imgs"></ciy-upload>
				</view>
			</view>
			<view class="ciy-form">
				<label>吨位</label>
				<view>
					<ciy-inputbet bb bet="1000000" unit="吨" :ciystyle="{width:'8em'}" name="ton" v-model="pagedata.demo.ton"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>单价</label>
				<view>
					<ciy-inputbet bet="100" unit="元" name="price" v-model="pagedata.demo.price"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>位置</label>
				<view>
					<ciy-selmap name="loc" v-model:lng="pagedata.demo.lng" v-model:lat="pagedata.demo.lat"></ciy-selmap>
				</view>
			</view>
			<view class="ciy-form">
				<label>监管数量</label>
				<view>
					<ciy-input name="nums" v-model="pagedata.demo.nums"></ciy-input>
				</view>
			</view>
			<view class="ciy-form">
				<label>百分比</label>
				<view>
					<ciy-inputbet bet="100" unit="%" name="pct" v-model="pagedata.demo.pct"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>链接</label>
				<view>
					<ciy-input name="url" v-model="pagedata.demo.url"></ciy-input>
				</view>
			</view>
			<view class="ciy-form">
				<label>体重</label>
				<view>
					<ciy-inputbet bet="1000" unit="公斤" name="weightg" v-model="pagedata.demo.weightg"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>耳温</label>
				<view>
					<ciy-inputbet bet="1000" unit="℃" name="eartmpr" v-model="pagedata.demo.eartmpr"></ciy-inputbet>
				</view>
			</view>
			<view class="ciy-form">
				<label>身份证号</label>
				<view>
					<ciy-input name="idcard" v-model="pagedata.demo.idcard"></ciy-input>
				</view>
			</view>
			<view class="ciy-form">
				<label>介绍</label>
				<view>
					<ciy-textarea name="content" v-model="pagedata.demo.content"></ciy-textarea>
				</view>
			</view>
			<!-- <view class="ciy-form v">
				<label>富文本</label>
				<view>
					<ciy-mdedit name="md" v-model="pagedata.demo.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() {
			if (!this.pagedata.demo)
				return this.alert('不能直接访问，请重新进入'); //独立进入写后端函数获取数据
			this.getdata();
		},
		watch: {},
		computed: {},
		methods: {
			async getdata() {
				var act = 'edit';
				var page = getApp().getpage(1);
				if (page && page.init._editonce)
					act = '';
				if (this._loading)
					return;
				this._loading = true;
				var retjson = await this.callajax({
					func: 'demo/demo.getdata',
					data: {
						...this.opn,
						act: act
					}
				});
				this._loading = false;
				if (retjson.code != 1)
					return this.init = retjson;
				if (act == 'edit') {
					page.init._editonce = true;
					page.g.zc_menu = retjson.zc_menu;
					this.g.zc_menu = retjson.zc_menu;
				}
				this.init = this.objdeepmerge(this.init, retjson);
			},
			async edited() {
				if (this._loading)
					return;
				this._loading = true;
				var retjson = await this.callajax({
					func: 'demo/demo.update',
					data: {
						...this.pagedata.demo
					}
				});
				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);
				// const eventChannel = this.getOpenerEventChannel();
				// eventChannel.emit('writedata', retjson.data);
				uni.navigateBack();
			}
		}
	}
</script>