<!-- 宣传报道 -->
<template>
	<view class="container">
		<scroll-view scroll-y style="padding-bottom: 180rpx;background-color: #fff;">
			<uni-forms v-model="form" label-width="200rpx">
				<ticketd :ticket_="form.ticket_"></ticketd>
				<uni-forms-item label="送审稿件标题" required>
					<uni-easyinput v-model="form.title" placeholder="请输入送审稿件标题" :disabled="mode=='show'"/>
				</uni-forms-item>
				<uni-forms-item label="文件内容" required>
					<xtUpload v-model="form.file" v-model:obj="form.file_" xtype="id" :disabled="mode=='show'"></xtUpload>
				</uni-forms-item>
				<uni-forms-item label="所有撰稿人" required>
					<uni-easyinput v-model="form.participants" placeholder="请输入所有撰稿人" :disabled="mode=='show'"/>
				</uni-forms-item>
				<uni-forms-item label="部室/研究院" required>
					<uni-easyinput v-model="form.pub_dept" placeholder="请输入部室/研究院" :disabled="mode=='show'"/>
				</uni-forms-item>
				<uni-forms-item label="第一撰稿人涉密等级">
					<uni-data-checkbox v-model="form.level" :localdata="hobby1"></uni-data-checkbox>
				</uni-forms-item>
				<uni-forms-item label="稿件内容涉及">
					<uni-data-checkbox multiple v-model="form.content" :localdata="hobby2"></uni-data-checkbox>
				</uni-forms-item>
				<uni-forms-item label="" v-if="(form.content || []).includes('其他')">
					<uni-easyinput v-model="form.other_content" placeholder="输入稿件名称" :disabled="mode=='show'"/>
				</uni-forms-item>
				<uni-forms-item label="宣传报道目的" required>
					<uni-easyinput v-model="form.report_purpose" placeholder="请输入宣传报道目的" :disabled="mode=='show'"/>
				</uni-forms-item>
				<uni-forms-item label="宣传渠道">
					<uni-data-checkbox multiple v-model="form.channel" :localdata="hobby3"></uni-data-checkbox>
				</uni-forms-item>
				<uni-forms-item label="" v-if="(form.channel || '').includes('其他')">
					<uni-easyinput v-model="form.other_channel" placeholder="请输入渠道名称" :disabled="mode=='show'"/>
				</uni-forms-item>
				<uni-forms-item label="第一撰稿人自审">
					<uni-data-checkbox v-model="form.review" :localdata="hobby4"></uni-data-checkbox>
				</uni-forms-item>
			</uni-forms>
		</scroll-view>
		<view class="footer_fixed">
			<ticketd_b :workflow_key="'wf_publicity'" :title="form.title + '-宣传报道'" :t_id="form.id" :ticket_="form.ticket_"
				@success="submitSuccess" :submit_b_func="submit_b_func" ref="ticketd_b_start"></ticketd_b>
		</view>
	</view>
</template>

<script>
import ticketd_b from "../wf/ticketd_b.vue"
import ticketd from "../wf/ticketd.vue"
import {actStateEnum} from "@/utils/enum.js"
import xtUpload from "@/components/xtUpload.vue"
	export default {
		components: { ticketd_b, ticketd,xtUpload },
		data(){
			return{
				form:{
					id:null,
					title:"",
					participants:"",
					pub_dept:"",
					level:"",
					content:"",
					other_content:"",
					report_purpose:"",
					channel:"",
					other_channel:"",
					review:"",
					ticket_:null,
				},
				hobby1:[
					{text: '重要',value: '重要'}, 
					{text: '一般',value: '一般'},
					{text: '非涉密',value: '非涉密'},
				],
				hobby2:[
					{text: '武器装备科研生产综合事项',value: '武器装备科研生产综合事项'},
					{text: '其他',value: '其他'},
				],
				hobby3:[
					{text: '互联网',value: '互联网'},
					{text: '信息平台',value: '信息平台'},
					{text: '官微',value: '官微'},
					{text: '公开发行物',value: '公开发行物'},
					{text: '其他',value: '其他'},
				],
				hobby4:[
					{text: '内容不涉及国家秘密和商业秘密，申请公开',value: '内容不涉及国家秘密和商业秘密，申请公开'},
					{text: '内容不涉及国家秘密、但涉及商业秘密，申请受控公开',value: '内容不涉及国家秘密、但涉及商业秘密，申请受控公开'},
					{text: '内容涉及国家秘密，申请按涉密渠道发布',value: '内容涉及国家秘密，申请按涉密渠道发布'},
				],
				vehicle_list:[{text: '市内', value: '市内'},{text: '市外', value: '市外'}],
			}
		},
		async onLoad(options) {
			let that = this;
			that.form.id='';
			that.mode = options.mode?options.mode:'show';
			that.t_id = options.t_id?options.t_id:null;
			if(that.mode != "add"){
				if(that.t_id) {
					that.form = await that.$api.publicItem(that.t_id);
					if(that.form.ticket_.state_.type == 1 && that.form.create_by == uni.getStorageSync("userInfo").id ) {
						that.mode = "edit";
					}else{
						that.mode = "show";
					}
				}
			}
		},
		methods:{
			//选择会议室和日期后查询有无预定
			async submit_b_func(id){
				let that = this;
				if (that.mode != 'show') {
					if(that.form.id) {
						await that.$api.publicUpdate(that.form.id, that.form);
					}else{
						let res = await that.$api.publicCreate(that.form);
						that.form.id = res.id;
					}
				}
			},
			submitSuccess(){
				uni.navigateTo({
					url: "/pages/index/index"
				})
			},
		}
	}
</script>

<style scoped>
	
</style>