Feedback.vue 7.68 KB
<template>
	<!-- 管理员查看页面 -->
	<view class="page" v-if="isAdmin">
		<!-- <zb-tab
		  :activeStyle="{
		    fontWeight: 'bold',
		    transform: 'scale(1.1)'
		    }"
		  :data="list"
		  v-model="active"
		 ></zb-tab> -->
		<view class="item-box" v-for="(it,index) in appealList" :key="index" @click="toReponse(it.id)">
			<view class="lef">
				{{it.content}}
			</view>
			<view class="rig">
				<view class="status" v-if="it.status == null" style="color: red;">
					未处理
				</view>
				<view class="status" v-else>
					{{it.status}}
				</view>
				<view class="button">
					<button >查看/处理</button>
				</view>
			</view>
		</view>
	</view>
	<!-- 普通用户页面 -->
	<view class="page" v-else>
		<!-- 反馈内容 -->
		<view class="feedback-data">
			<view class="titleall-box">
				<view class="titleall-left"><view class="titleall-left-line"></view>填写诉求</view>
			</view>
			<view class="content">
				<textarea v-model="requires" placeholder="请填写您的诉求..." />
			</view>
			<uni-section title="表单校验" type="line">
				<view class="example">
					<!-- 基础表单校验 -->
					<uni-forms ref="valiForm" :rules="rules" :modelValue="valiFormData" style="width: 95%;margin: 0 auto;">
						<uni-forms-item label="企业名称">
							<uni-easyinput v-model="valiFormData.companyName" placeholder="请输入企业名称" />
						</uni-forms-item>
						<uni-forms-item label="联系人" required name="contactPeople">
							<uni-easyinput v-model="valiFormData.contactPeople" placeholder="请输入联系人名字" />
						</uni-forms-item>
						<uni-forms-item label="联系人电话" required name="contactPhone">
							<uni-easyinput v-model="valiFormData.contactPhone" placeholder="请输入联系人电话" />
						</uni-forms-item>
					</uni-forms>
					<!-- <button type="primary" @click="submit('valiForm')">提交</button> -->
				</view>
			</uni-section>
			<!-- <view class="voucher-img">
				<view class="list">
					<image src="/static/voucher_bg.png"></image>
				</view>
				<view class="list">
					<image src="/static/img/yf_01.png"></image>
				</view>
				<view class="list">
					<image src="/static/img/yf_01.png"></image>
				</view>
			</view> -->
		</view>
		<!-- 选择反馈类型 -->
		<view class="feedback-type">
			<view class="feedback-type-left">隶属类别</view>
			<view class="feedback-type-right">
				<view class="title">
					<text>{{TypeArray[TypeIndex]}}</text>
				</view>
				<view class="picker">
					<picker @change="FeedbackTypeCh" :value="TypeIndex" :range="TypeArray">
							<view class="uni-input">{{TypeArray[TypeIndex]}}</view>
					</picker>
				</view>
				<view class="more">
					<image src="../../static/down1.png"></image>
				</view>
			</view>
		</view>
		<!-- 提交 -->
		<view class="submit-btn" @click="submitContent('valiForm')">
			<text>提交</text>
		</view>
	</view>
	
	
</template>

<script>
import { data } from '../../uview-ui/libs/mixin/mixin';
import request from '@/utils/request.js'
import { use } from 'echarts';
	export default {
		data() {
			return {
				TypeArray: ['行政审批', '生产运营', '金融服务', '其他'],
				TypeIndex: 0,
				// 填写诉求内容
				requires:'',
				type:"",
				lastModifyUserId:'',
				userCode:'',
				list:[{
				    name: '未处理',
				    value: 0,
				}, {
				    name: '已处理',
				    value: 1,
				}, {
				    name: '忽略',
				    value: 2,
				}, {
				    name: '无效',
				    value: 3,
				}],
				appealList:[],
				isAdmin:false,
				valiFormData: {
					title: '',
					subTitle: '',
					bodyContent: '',
					post: '',
					phone:'',
					companyName:'',
					contactPeople:'',
					contactPhone:''
				},
				rules: {
					title: {
						rules: [{
							required: true,
							errorMessage: '企业名称不能为空'
						}]
					},
					post: {
						rules: [{
							required: true,
							errorMessage: '岗位名不能为空'
						}]
					},
					subTitle: {
						rules: [{
							required: true,
							errorMessage: '介绍不能为空'
						}]
					},
					contactPeople: {
						rules: [{
							required: true,
							errorMessage: '联系人不能为空'
						}]
					},
					contactPhone: {
						rules: [{
							required: true,
							errorMessage: '联系人电话不能为空'
						}]
					},
				},
			};
			
		},
		onShow() {
			this.getUser()
			let user = uni.getStorageSync('user')
			this.lastModifyUserId = user.userInfo.userId
			this.getAppealList()
		},
		// onLoad() {
		// 	this.getUser()
		// 	let user = uni.getStorageSync('user')
		// 	this.lastModifyUserId = user.userInfo.userId
		// 	this.getAppealList()
		// },
		// onLoad() {
		// 	if (uni.getStorageSync('user')) {
		// 		let userCode = uni.getStorageSync('user')
		// 		// console.log("用户的code", this.userCode)
		// 		console.log('用户信息',userCode)
		// 	}
		// },
		methods:{
			// 获取用户信息判断是否有诉求管理的ID,权限判断authority = 359968822326723845
			getUser(){
				if (uni.getStorageSync('user')) {
					let userCode = uni.getStorageSync('user')
					console.log('this.userCode',userCode)
					this.userCode = userCode
					// this.userInfo = this.userCode.userAccount
					// this.userInfo = '123456'
					let authorityID = userCode.permissionList
					this.valiFormData.companyName = this.userCode.userInfo.userName
					this.isAdmin = authorityID.some(it => it.modelId === '359968822326723845')
					// if(!this.isAdmin){
					// 	uni.showToast({
					// 		icon:"error",
					// 		title:"您无该权限!"
					// 	})
					// }
					console.log('是否有诉求管理权限',this.isAdmin)
					console.log(userCode)
					console.log('用户已登录!')
				} else {
					uni.showToast({
						title: '请登录',
						icon: 'none'
					})
					setTimeout(() => {
						uni.reLaunch({
							url: '/pages/login/index'
						})
					})
				}
			},
			// 提交内容
			submitContent(ref){
				let that = this
				this.$refs[ref].validate().then(res => {
					let query = {
						content:this.requires,
						type:this.TypeArray[this.TypeIndex],
						creatorUserId:this.lastModifyUserId,
						lastModifyUserId:this.lastModifyUserId,
						plate:'诉求模块',
						companyName:this.valiFormData.companyName,
						userName:this.valiFormData.contactPeople,
						userPhone:this.valiFormData.contactPhone
					}
					console.log(query)
					request({
						url: '/api/Extend/baseappealinformation',
						method: 'post',
						data: {
							content:this.requires,
							type:this.TypeArray[this.TypeIndex],
							creatorUserId:this.lastModifyUserId,
							lastModifyUserId:this.lastModifyUserId,
							plate:'诉求模块',
							companyName:this.valiFormData.companyName,
							userName:this.valiFormData.contactPeople,
							userPhone:this.valiFormData.contactPhone
						},
					}).then(res=>{
						console.log(res)
						if(res.code === 200){
							uni.showToast({
								icon:"success",
								title:"提交成功"
							})
						}else{
							uni.showToast({
								icon:"error",
								title:'提交失败'
							})
						}
					})
				})
			},
			/**
			 * 反馈类型
			 * @param {Object} val
			 */
			FeedbackTypeCh(val){
				console.log(val);
				this.TypeIndex = val.detail.value;
			},
			// 获取诉求列表
			getAppealList(){
				request({
					url:'/api/Extend/baseappealinformation',
					method:'get',
					data:{
						pageSize:10000,
						// status:status
					}
				}).then(res=>{
					console.log(res)
					if(res.code === 200){
						this.appealList = res.data.list
					}
				})
			},
			// 跳转到查看和修改页面
			toReponse(id){
				uni.navigateTo({
					url:'/pages/Feedback/reponseAppeal/reponseAppeal?data=' + JSON.stringify(id)
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	@import 'Feedback.scss';
</style>