<!-- 宣传报道 -->
<template>
	<view class="form-page">
		<scroll-view scroll-y class="form-scroll">
			<uni-forms v-model="form" label-width="260upx">
				<view class="form-card" v-if="form.ticket_">
					<ticketd :ticket_="form.ticket_"></ticketd>
				</view>
				<view class="form-card">
					<view class="form-card-title">宣传报道</view>
				<uni-forms-item label="送审稿件标题" required>
					<uni-easyinput v-model="form.title" placeholder="请输入送审稿件标题" v-if="mode!='show'"/>
					<span v-else>{{form.title}}</span>
				</uni-forms-item>
				<uni-forms-item label="文件内容" required>
					<xtUpload v-model="form.pfile" xtype="path" v-if="mode!='show'"></xtUpload>
					<view v-else style="color:blue" @click="preview(form.pfile)">{{ form.pfile}}</view>
				</uni-forms-item>
				<uni-forms-item label="所有撰稿人" required>
					<uni-easyinput v-model="form.participants" placeholder="请输入所有撰稿人" v-if="mode!='show'"/>
					<span v-else>{{form.participants}}</span>
				</uni-forms-item>
				<uni-forms-item label="部室/研究院" required>
					<uni-easyinput v-model="form.pub_dept" placeholder="请输入部室/研究院" v-if="mode!='show'"/>
					<span v-else>{{form.pub_dept}}</span>
				</uni-forms-item>
				<uni-forms-item label="第一撰稿人涉密等级">
					<uni-data-checkbox v-model="form.level" :localdata="hobby1" :disabled="mode=='show'"></uni-data-checkbox>
				</uni-forms-item>
				<uni-forms-item label="稿件内容涉及">
					<uni-data-checkbox multiple v-model="form.content" :localdata="hobby2" :disabled="mode=='show'"></uni-data-checkbox>
				</uni-forms-item>
				<uni-forms-item label="" v-if="(form.content || []).includes('其他')">
					<uni-easyinput v-model="form.other_content" placeholder="输入稿件名称" v-if="mode!='show'"/>
					<span v-else>{{form.other_content}}</span>
				</uni-forms-item>
				<uni-forms-item label="宣传报道目的" required>
					<uni-easyinput v-model="form.report_purpose" placeholder="请输入宣传报道目的" v-if="mode!='show'"/>
					<span v-else>{{form.report_purpose}}</span>
				</uni-forms-item>
				<uni-forms-item label="宣传渠道">
					<uni-data-checkbox multiple v-model="form.channel" :localdata="hobby3" :disabled="mode=='show'"></uni-data-checkbox>
				</uni-forms-item>
				<uni-forms-item label="" v-if="form.channel=='其他'">
					<uni-easyinput v-model="form.other_content" placeholder="请输入渠道名称" v-if="mode!='show'"/>
					<span v-else>{{form.other_content}}</span>
				</uni-forms-item>
				<uni-forms-item label="第一撰稿人自审">
					<uni-data-checkbox v-model="form.review" :localdata="hobby4" :disabled="mode=='show'"></uni-data-checkbox>
				</uni-forms-item>
				<view  v-if="['部门领导审批', '总经理审批', '结束'].includes(form.ticket_?.state_?.name)">
					<uni-forms-item label="所在部室定密意见">
						<uni-data-checkbox v-model="form.dept_opinion" :localdata="hobby5" :disabled="mode=='show'&&form.ticket_.state_.name=='总经理审批'"></uni-data-checkbox>
					</uni-forms-item>
					<view label="" v-if="form.dept_opinion === '不符合定密要求'" class="formText">
						<text style="display: inline-block;margin-right: 30upx;">应做 </text>
						<uni-data-checkbox v-model="form.publicity_opinion" :localdata="hobby50" style="display: inline-block;" :disabled="mode=='show'&&form.ticket_.state_.name=='总经理审批'"></uni-data-checkbox>
						<text>处理。</text>
					</view>
					<uni-forms-item label="" v-if="form.dept_opinion === '同意内容为涉密事项'">
						<text>涉密等级为：</text>
						<uni-data-checkbox v-model="form.secret_level" :localdata="hobby51"  :disabled="mode=='show'&&form.ticket_.state_.name=='总经理审批'"></uni-data-checkbox>
					</uni-forms-item>
					<view v-if="form.dept_opinion === '同意内容为涉密事项'" class="formText">
						<text>，保密期限（解密时间或解密条件）为：</text>
						<uni-easyinput v-model="form.secret_period" placeholder="请输入期限" class="formInput" :disabled="mode=='show'"/>
						<text>，请按总院管理要求做好保密管理。</text>
					</view>
					
					<uni-forms-item label="综合管理部审查意见">
						<uni-data-checkbox v-model="form.dept_opinion_review" :localdata="hobby6" :disabled="mode=='show'&&form.ticket_.state_.name=='总经理审批'"></uni-data-checkbox>
					</uni-forms-item>
				</view>
				<uni-forms-item label="总经理审查意见" v-if="['总经理审批', '结束'].includes(form.ticket_?.state_?.name)">
					<uni-data-checkbox v-model="form.publicity_opinion" :localdata="hobby7" ></uni-data-checkbox>
				</uni-forms-item>
				</view>
			</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"
import config from './../../utils/config.js'
	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: '内容涉及国家秘密，申请按涉密渠道发布'},
				],
				hobby5:[
					{text: '不符合定密要求',value: '不符合定密要求'}, 
					{text: '同意内容为涉密事项',value: '同意内容为涉密事项'}
				],
				hobby50:[
					{text: '公开',value: '公开'}, 
					{text: '受控',value: '受控'}
				],
				hobby51:[
					{text: '机密',value: '机密'}, 
					{text: '秘密',value: '秘密'}
				],
				hobby6:[
					{text: '内容不涉及国家秘密和商业秘密，同意公开',value: '内容不涉及国家秘密和商业秘密，同意公开'}, 
					{text: '内容不涉及国家秘密、但涉及商业秘密，同意受控公开',value: '内容不涉及国家秘密、但涉及商业秘密，同意受控公开'},
					{text: '内容涉及国家秘密，同意按涉密渠道发布',value: '内容涉及国家秘密，同意按涉密渠道发布'},
				],
				hobby7:[
					{text: '同意公开宣传报道',value: '同意公开宣传报道'}, 
					{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"
				})
			},
			preview(pfile){
				let baseUrl = config.baseUrl.split('/api')[0];
				let url = baseUrl+pfile;
				let urls = [];
				urls.push(url)
				if (pfile.indexOf('jpg')>-1||pfile.indexOf('png')>-1||pfile.indexOf('jpeg')>-1) {
					uni.previewImage({
						urls: urls,
						fail: function(err) {
							uni.showToast({
							    title: "预览失败",
								icon: "none"
							})
						}
					})
				} else {
					window.open(url, '_blank');
				}
			}
			
		}
	}
</script>

<style lang="scss" scoped>
.form-page { min-height: 100vh; background: #F0F2F5; }
.form-scroll { padding: 0; padding-bottom: 180rpx; }
.form-card { background: #fff; border-radius: 0; padding: 24rpx; margin-bottom: 0; box-shadow: none; }
.form-card-title { font-size: 30rpx; font-weight: 600; color: #1F2937; margin-bottom: 16rpx; padding-left: 16rpx; border-left: 6rpx solid #2BA471; }
.form-textarea { width: 100%; min-height: 160rpx; border: 2rpx solid #E5E7EB; border-radius: 12rpx; padding: 16rpx; font-size: 28rpx; color: #374151; box-sizing: border-box; background: #F9FAFB; }
.form-btn { flex: 1; height: 80rpx; line-height: 80rpx; border-radius: 14rpx !important; font-size: 28rpx; font-weight: 500; border: none !important; }
.form-btn-primary { background: linear-gradient(135deg, #2BA471, #1F8C5E) !important; color: #fff !important; box-shadow: 0 4rpx 12rpx rgba(43,164,113,0.2); }
.form-btn-danger { background: linear-gradient(135deg, #EF4444, #DC2626) !important; color: #fff !important; box-shadow: 0 4rpx 12rpx rgba(239,68,68,0.3); }
.formText{
	color: #666;
	font-size: 14px;
	padding-left: 200upx;
}
.formInput{
	width:170upx;
	display: inline-block;
}
</style>