Browse Source

人大代表,内容管理 修改界面增加日期字段

jly/task
LAPTOP-7F135LL2\jly 3 years ago
parent
commit
4e9942fdf8
  1. 105
      src/views/modules/member/newsmember-add-or-update.vue

105
src/views/modules/member/newsmember-add-or-update.vue

@ -11,7 +11,9 @@
:label-width="$i18n.locale === 'en-US' ? '120px' : '80px'"> :label-width="$i18n.locale === 'en-US' ? '120px' : '80px'">
<el-form-item label="所属模块" <el-form-item label="所属模块"
prop="businessId"> prop="businessId">
<el-select v-model="dataForm.businessId" @change="businessChange" ref="businessName" <el-select v-model="dataForm.businessId"
@change="businessChange"
ref="businessName"
placeholder="请选择模块"> placeholder="请选择模块">
<el-option v-for="item in options" <el-option v-for="item in options"
:key="item.code" :key="item.code"
@ -20,10 +22,13 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="所属类别" v-if="trueOrFalse" <el-form-item label="所属类别"
v-if="trueOrFalse"
prop="categoryId"> prop="categoryId">
<el-select v-model="dataForm.newsCateroryId" :disabled="!dataForm.businessId" <el-select v-model="dataForm.newsCateroryId"
@change="categoryChange" ref="newsCateroryName" :disabled="!dataForm.businessId"
@change="categoryChange"
ref="newsCateroryName"
placeholder="请选择类别"> placeholder="请选择类别">
<el-option v-for="item in categorys" <el-option v-for="item in categorys"
:key="item.id" :key="item.id"
@ -32,10 +37,13 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="所属栏目" v-if="trueOrFalse" <el-form-item label="所属栏目"
v-if="trueOrFalse"
prop="newsSubCateroryId"> prop="newsSubCateroryId">
<el-select v-model="dataForm.newsSubCateroryId" :disabled="!dataForm.newsCateroryId" <el-select v-model="dataForm.newsSubCateroryId"
placeholder="请选择栏目" ref="newsSubCateroryName"> :disabled="!dataForm.newsCateroryId"
placeholder="请选择栏目"
ref="newsSubCateroryName">
<el-option v-for="item in subCategorys" <el-option v-for="item in subCategorys"
:key="item.id" :key="item.id"
:label="item.categoryName" :label="item.categoryName"
@ -43,6 +51,15 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="日期"
prop="createdTime">
<el-date-picker v-model="dataForm.createdTime"
format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
placeholder="选择日期时间">
</el-date-picker>
</el-form-item>
<el-form-item label="标题" <el-form-item label="标题"
prop="title"> prop="title">
<el-form-item> <el-form-item>
@ -71,8 +88,7 @@
<el-form-item label="新闻首图" <el-form-item label="新闻首图"
v-loading="loading" v-loading="loading"
prop="newsImageUrl"> prop="newsImageUrl">
<el-upload <el-upload ref="upload"
ref="upload"
:action="uploadUrl" :action="uploadUrl"
list-type="picture-card" list-type="picture-card"
:file-list="dataForm.images" :file-list="dataForm.images"
@ -103,21 +119,23 @@
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> <el-button @click="visible = false">{{ $t('cancel') }}</el-button>
<el-button type="primary" <el-button type="primary"
@click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button>
<el-button v-if="dataForm.releaseState === '1'" type="primary" @click="dataFormReleaseHandle()">提报</el-button> <el-button v-if="dataForm.releaseState === '1'"
type="primary"
@click="dataFormReleaseHandle()">提报</el-button>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import mixinViewModule from '@/mixins/view-module'
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import debounce from 'lodash/debounce' import debounce from 'lodash/debounce'
import 'quill/dist/quill.snow.css'
import Quill from 'quill' import Quill from 'quill'
import mixinViewModule from '@/mixins/view-module' import 'quill/dist/quill.snow.css'
import AddOrUpdate from './newsmember-add-or-update' import AddOrUpdate from './newsmember-add-or-update'
export default { export default {
mixins: [mixinViewModule], mixins: [mixinViewModule],
data () { data() {
return { return {
mixinViewModuleOptions: { mixinViewModuleOptions: {
getDataListURL: '/news/newsmember/page', getDataListURL: '/news/newsmember/page',
@ -174,7 +192,7 @@ export default {
visible: false visible: false
} }
}, },
created () { created() {
this.getListCategory() this.getListCategory()
this.visible = true this.visible = true
this.$nextTick(() => { this.$nextTick(() => {
@ -190,7 +208,7 @@ export default {
}) })
}, },
computed: { computed: {
dataRule () { dataRule() {
return { return {
businessId: [ businessId: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } { required: true, message: this.$t('validate.required'), trigger: 'blur' }
@ -212,7 +230,7 @@ export default {
}, },
methods: { methods: {
init () { init() {
this.visible = true this.visible = true
this.$nextTick(() => { this.$nextTick(() => {
this.$refs['dataForm'].resetFields() this.$refs['dataForm'].resetFields()
@ -221,12 +239,12 @@ export default {
} }
}) })
}, },
handleRemove (file, fileList) { handleRemove(file, fileList) {
this.dataForm.images=[] this.dataForm.images = []
this.dataForm.newsImageUrl='' this.dataForm.newsImageUrl = ''
}, },
businessChange (item) { businessChange(item) {
this.dataForm.newsCateroryId = '' this.dataForm.newsCateroryId = ''
this.dataForm.newsSubCateroryId = '' this.dataForm.newsSubCateroryId = ''
// //
@ -239,7 +257,7 @@ export default {
this.loading = false this.loading = false
this.categorys = res.data this.categorys = res.data
this.trueOrFalse = true this.trueOrFalse = true
if(res.data.length===0){ if (res.data.length === 0) {
this.trueOrFalse = false this.trueOrFalse = false
} }
}) })
@ -247,7 +265,7 @@ export default {
this.loading = false this.loading = false
}) })
}, },
categoryChange (item) { categoryChange(item) {
this.dataForm.newsSubCateroryId = '' this.dataForm.newsSubCateroryId = ''
// //
this.$http this.$http
@ -264,16 +282,16 @@ export default {
}) })
}, },
// //
getInfo () { getInfo() {
this.loading = true this.loading = true
this.$http.get(`/news/newsmember/${this.dataForm.id}`).then(({ data: res }) => { this.$http.get(`/news/newsmember/${this.dataForm.id}`).then(({ data: res }) => {
if (res.code !== 0) { if (res.code !== 0) {
return this.$message.error(res.msg) return this.$message.error(res.msg)
} }
this.dataForm = { ...this.dataForm, ...res.data } this.dataForm = { ...this.dataForm, ...res.data }
this.dataForm.images=[] this.dataForm.images = []
if(res.data.newsImageUrl){ if (res.data.newsImageUrl) {
this.dataForm.images.push({ url: res.data.newsImageUrl}) this.dataForm.images.push({ url: res.data.newsImageUrl })
} }
this.quillEditor.root.innerHTML = res.data.newsContent this.quillEditor.root.innerHTML = res.data.newsContent
@ -287,7 +305,7 @@ export default {
this.loading = false this.loading = false
this.categorys = res.data this.categorys = res.data
this.trueOrFalse = true this.trueOrFalse = true
if(res.data.length===0){ if (res.data.length === 0) {
this.trueOrFalse = false this.trueOrFalse = false
} }
}) })
@ -313,7 +331,7 @@ export default {
}) })
}, },
// //
getDeptInfoList (dataReceiver, faDeptId) { getDeptInfoList(dataReceiver, faDeptId) {
if (!faDeptId) { if (!faDeptId) {
return return
} }
@ -331,30 +349,30 @@ export default {
} }
}).catch(() => { }) }).catch(() => { })
}, },
changeStreet (event) { changeStreet(event) {
let choosenItem = this.streetList.filter(item => item.id === this.dataForm.streetId)[0] let choosenItem = this.streetList.filter(item => item.id === this.dataForm.streetId)[0]
this.dataForm.street = choosenItem.name this.dataForm.street = choosenItem.name
this.dataForm.communityId = this.dataForm.deptId = this.dataForm.community = this.dataForm.grid = null this.dataForm.communityId = this.dataForm.deptId = this.dataForm.community = this.dataForm.grid = null
this.communityList = this.gridList = [] this.communityList = this.gridList = []
this.getDeptInfoList('community', event) this.getDeptInfoList('community', event)
}, },
changeCommunity (event) { changeCommunity(event) {
let choosenItem = this.communityList.filter(item => item.id === this.dataForm.communityId)[0] let choosenItem = this.communityList.filter(item => item.id === this.dataForm.communityId)[0]
this.dataForm.community = choosenItem.name this.dataForm.community = choosenItem.name
this.dataForm.deptId = this.dataForm.grid = null this.dataForm.deptId = this.dataForm.grid = null
this.gridList = [] this.gridList = []
this.getDeptInfoList('grid', event) this.getDeptInfoList('grid', event)
}, },
changeGrid (event) { changeGrid(event) {
let choosenItem = this.gridList.filter(item => item.id === this.dataForm.deptId)[0] let choosenItem = this.gridList.filter(item => item.id === this.dataForm.deptId)[0]
this.dataForm.grid = choosenItem.name this.dataForm.grid = choosenItem.name
}, },
changeCategory () { changeCategory() {
// //
let choosenItem = this.categorys.filter(item => item.id === this.dataForm.categoryId)[0] let choosenItem = this.categorys.filter(item => item.id === this.dataForm.categoryId)[0]
this.dataForm.categoryName = choosenItem.name this.dataForm.categoryName = choosenItem.name
}, },
getListCategory () { getListCategory() {
this.$http this.$http
.get(`/news/newsmembermenu/options/0`) .get(`/news/newsmembermenu/options/0`)
.then(({ data: res }) => { .then(({ data: res }) => {
@ -369,7 +387,7 @@ export default {
}) })
}, },
// //
quillEditorHandle () { quillEditorHandle() {
this.quillEditor = new Quill('#J_quillEditor', { this.quillEditor = new Quill('#J_quillEditor', {
modules: { modules: {
toolbar: this.quillEditorToolbarOptions toolbar: this.quillEditorToolbarOptions
@ -390,46 +408,46 @@ export default {
}) })
}, },
// () // ()
uploadBeforeUploadHandle (file) { uploadBeforeUploadHandle(file) {
if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') { if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') {
this.$message.error(this.$t('upload.tip', { 'format': 'jpg、png、gif' })) this.$message.error(this.$t('upload.tip', { 'format': 'jpg、png、gif' }))
return false return false
} }
}, },
// () // ()
uploadSuccessHandle (res, file, fileList) { uploadSuccessHandle(res, file, fileList) {
if (res.code !== 0) { if (res.code !== 0) {
return this.$message.error(res.msg) return this.$message.error(res.msg)
} }
this.quillEditor.insertEmbed(this.quillEditor.getSelection().index, 'image', res.data.thumbnail) this.quillEditor.insertEmbed(this.quillEditor.getSelection().index, 'image', res.data.thumbnail)
}, },
// //
handleAvatarSuccess (res, file) { handleAvatarSuccess(res, file) {
this.loading = false this.loading = false
this.dataForm.newsImageUrl = res.data.thumbnail this.dataForm.newsImageUrl = res.data.thumbnail
}, },
beforeAvatarUpload (file) { beforeAvatarUpload(file) {
this.loading = true this.loading = true
}, },
setRegistTime () { setRegistTime() {
this.dataForm.releaseStartTime = this.time[0] this.dataForm.releaseStartTime = this.time[0]
this.dataForm.releaseEndTime = this.time[1] this.dataForm.releaseEndTime = this.time[1]
}, },
resetRegistTime () { resetRegistTime() {
this.time = [this.dataForm.releaseStartTime.substr(0, 10), this.dataForm.releaseEndTime.substr(0, 10)] this.time = [this.dataForm.releaseStartTime.substr(0, 10), this.dataForm.releaseEndTime.substr(0, 10)]
}, },
// end // end
dataFormReleaseHandle () { dataFormReleaseHandle() {
this.dataForm.releaseState = 0 this.dataForm.releaseState = 0
this.dataFormSubmitHandle() this.dataFormSubmitHandle()
}, },
// //
dataFormSubmitHandle: debounce(function () { dataFormSubmitHandle: debounce(function () {
this.loading = true this.loading = true
if(this.trueOrFalse){ if (this.trueOrFalse) {
this.dataForm.newsProperty = this.$refs.newsCateroryName.selectedLabel this.dataForm.newsProperty = this.$refs.newsCateroryName.selectedLabel
this.dataForm.newsColumn = this.$refs.newsSubCateroryName.selectedLabel this.dataForm.newsColumn = this.$refs.newsSubCateroryName.selectedLabel
}else{ } else {
this.dataForm.newsCateroryId = '' this.dataForm.newsCateroryId = ''
this.dataForm.newsSubCateroryId = '' this.dataForm.newsSubCateroryId = ''
this.dataForm.newsColumn = '' this.dataForm.newsColumn = ''
@ -494,5 +512,4 @@ export default {
height: 178px; height: 178px;
display: block; display: block;
} }
</style> </style>

Loading…
Cancel
Save