城阳pc工作端前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

235 lines
5.2 KiB

3 years ago
<template>
3 years ago
<div>
<div class="dialog-h-content scroll-h">
<el-form ref="ref_form"
:inline="true"
:model="formData"
class="div_form ">
<el-form-item label="活动回顾"
prop="actContent"
label-width="150px">
<!-- <div style="width:400px"> -->
<Tinymce class="tinymce_view"
v-if="formType!='detail'"
v-model="formData.actContent"
:height="450"
style="width:1000px"
:customerId="customerId"
placeholder="在这里输入文字" />
<p v-else
class="text_p"
v-html="formData.actContent"></p>
<!-- </div> -->
</el-form-item>
</el-form>
3 years ago
</div>
3 years ago
<div class="div_btn">
<el-button size="small"
@click="handleCancle"> </el-button>
<el-button size="small"
v-if="formType != 'detail'"
type="primary"
:disabled="btnDisable"
@click="handleComfirm"> </el-button>
</div>
3 years ago
</div>
</template>
<script>
import { mapGetters } from 'vuex'
import { Loading } from 'element-ui' // 引入Loading服务
import { requestPost } from '@/js/dai/request'
3 years ago
import Tinymce from '@c/tinymce2/index.vue'
3 years ago
let loading // 加载动画
3 years ago
3 years ago
export default {
data () {
3 years ago
3 years ago
return {
3 years ago
formType: 'add', //表单操作类型 add新增,edit编辑,detail详情
btnDisable: false,
customerId: '',
actId: '',
formData: {
actContent: '',
},
3 years ago
}
},
3 years ago
components: { Tinymce },
3 years ago
mounted () {
3 years ago
this.customerId = localStorage.getItem('customerId')
3 years ago
},
methods: {
3 years ago
async initForm (type, actId) {
this.$refs.ref_form.resetFields();
this.startLoading()
3 years ago
3 years ago
this.formType = type
if (actId) {
this.actId = actId
this.formData.actId = actId
3 years ago
}
3 years ago
this.endLoading()
3 years ago
},
3 years ago
async handleComfirm () {
console.log(this.formData)
// this.btnDisable = true
// setTimeout(() => {
// this.btnDisable = false
// }, 10000)
// this.$refs['ref_form'].validate((valid, messageObj) => {
// if (!valid) {
// app.util.validateRule(messageObj)
// this.btnDisable = false
// } else {
// this.addRecord()
// }
3 years ago
3 years ago
// })
3 years ago
},
3 years ago
async addRecord () {
this.formData.actContent = this.dormatHtml(this.formData.actContent)
3 years ago
3 years ago
let url = "/gov/org/placepatrolrecord/add"
// let url = "http://yapi.elinkservice.cn/mock/245/gov/org/placepatrolrecord/add"
this.formData.inspectors = this.formData.inspectorArray.join(',')
3 years ago
3 years ago
const { data, code, msg } = await requestPost(url, this.formData)
3 years ago
3 years ago
if (code === 0) {
3 years ago
this.$message({
3 years ago
type: 'success',
message: '操作成功'
3 years ago
})
3 years ago
this.resetData()
this.$emit('dialogOk')
this.btnDisable = false
3 years ago
} else {
3 years ago
this.btnDisable = false
3 years ago
this.$message.error(msg)
}
},
3 years ago
dormatHtml (content) {
let c = ''
if (content.indexOf('DOCTYPE') != -1) {
c = content.slice(45, -16);
3 years ago
}
3 years ago
console.log('content', typeof content)
return c || content
3 years ago
},
handleCancle () {
3 years ago
this.resetData()
3 years ago
this.$emit('dialogCancle')
},
3 years ago
resetData () {
this.formData = {
actContent: '',
}
},
3 years ago
// 开启加载动画
startLoading () {
loading = Loading.service({
lock: true, // 是否锁定
text: '正在加载……', // 加载中需要显示的文字
background: 'rgba(0,0,0,.7)' // 背景颜色
})
},
// 结束加载动画
endLoading () {
// clearTimeout(timer);
if (loading) {
loading.close()
}
}
},
computed: {
3 years ago
dataRule () {
return {
gridId: [
{ required: true, message: '场所网格不能为空', trigger: 'blur' }
],
ninePlaceVal: [
{ required: true, message: '场所类型不能为空', trigger: 'blur' },
],
placeOrgId: [
{ required: true, message: '场所名称不能为空', trigger: 'blur' }
],
placePatrolTeamId: [
{ required: true, message: '分队不能为空', trigger: 'blur' }
],
inspectorArray: [
{ required: true, message: '巡检人员不能为空', trigger: 'blur' }
],
firstTime: [
{ required: true, message: '首次巡查时间不能为空', trigger: 'blur' }
],
detailed: [
{ required: true, message: '隐患明细不能为空', trigger: 'blur' }
],
firstResult: [
{ required: true, message: '首次巡查结果不能为空', trigger: 'blur' }
]
}
3 years ago
},
},
props: {
}
}
</script>
<style lang="scss" scoped >
3 years ago
@import "@/assets/scss/modules/management/form-main.scss";
.avatar-uploader {
margin: 0 0 0 20px;
3 years ago
}
3 years ago
</style>
<style lang="scss">
.el-dialog__body {
padding: 0 10px 20px !important;
3 years ago
}
3 years ago
.hide {
.el-upload--picture-card {
display: none !important;
3 years ago
}
}
</style>
3 years ago