Browse Source

政策部分功能添加

master
rose 4 years ago
parent
commit
b1b810acb4
  1. 1
      package.json
  2. 3
      src/main.js
  3. 6
      src/utils/request.js
  4. 83
      src/views/firstPages/policy.vue

1
package.json

@ -18,6 +18,7 @@
"core-js": "3.6.5",
"element-ui": "2.13.2",
"js-cookie": "2.2.0",
"moment": "^2.29.1",
"node-sass": "^4.14.1",
"normalize.css": "7.0.0",
"nprogress": "0.2.0",

3
src/main.js

@ -5,6 +5,7 @@ import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n
import moment from 'moment'
import '@/styles/index.scss' // global css
@ -32,6 +33,8 @@ Vue.use(ElementUI)
// 如果想要中文版 element-ui,按如下方式声明
// Vue.use(ElementUI)
Vue.prototype.$moment = moment
Vue.config.productionTip = false
new Vue({

6
src/utils/request.js

@ -30,7 +30,7 @@ service.interceptors.response.use(
// if the custom code is not 20000, it is judged as an error.
if (res.code !== 200) {
Message({
message: res.message || 'Error',
message: res.msg || 'Error',
type: 'error',
duration: 5 * 1000
})
@ -48,7 +48,7 @@ service.interceptors.response.use(
})
})
}
return Promise.reject(new Error(res.message || 'Error'))
return Promise.reject(new Error(res.msg || 'Error'))
} else {
return res.data
}
@ -56,7 +56,7 @@ service.interceptors.response.use(
error => {
console.log('err' + error) // for debug
Message({
message: error.message,
message: error.msg,
type: 'error',
duration: 5 * 1000
})

83
src/views/firstPages/policy.vue

@ -195,7 +195,12 @@
</el-form-item>
<el-form-item label="发布部门" prop="imgUrl" style="width: 180%">
<el-select v-model="temp.pushDep" placeholder="请选择">
<el-select
:value="temp.pushDep===4 ? '': temp.pushDep"
clearable
placeholder="请选择"
@change="changePushDep"
>
<el-option
v-for="item in options"
:key="item.value"
@ -203,13 +208,6 @@
:value="item.value"
/>
</el-select>
<!-- <el-cascader
v-if="options.length > 0"
v-model="cascader"
:options="options"
:props="{ value: 'id', label: 'areaName', children: 'next' }"
@change="handleChange"
/> -->
</el-form-item>
<el-form-item label="原文内容" prop="content" style="width: 180%">
@ -240,7 +238,7 @@
<el-form-item label="政策标签" prop="intro" style="width: 180%">
<!-- <el-button @click="addLabel">添加标签</el-button> -->
<el-select v-model="temp.projectLabels" multiple-limit="5" multiple placeholder="请选择标签">
<el-select v-model="temp.projectLabels" :multiple-limit="5" multiple placeholder="请选择标签">
<el-option
v-for="item in projectLabels"
:key="item.name"
@ -321,7 +319,7 @@
</el-form-item>
<el-form-item label="发布部门" prop="imgUrl" style="width: 180%">
<el-select v-model="value" placeholder="请选择">
<el-select v-model="addPolicy.pushDep" clearable placeholder="请选择">
<el-option
v-for="item in options"
:key="item.value"
@ -329,13 +327,7 @@
:value="item.value"
/>
</el-select>
<!-- <el-cascader
v-if="options.length > 0"
v-model="cascader1"
:options="options"
:props="{ value: 'id', label: 'areaName', children: 'next' }"
@change="handleChange1"
/> -->
</el-form-item>
<el-form-item label="原文内容" prop="content" style="width: 180%">
@ -376,7 +368,7 @@
import { mapGetters } from 'vuex'
import * as api from '@/api/policy'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import { Message } from 'element-ui'
export default {
name: 'Policy',
components: { Pagination },
@ -421,23 +413,33 @@ export default {
pushDep: ''
},
options: [{
value: '0',
value: 0,
label: '部委政策'
}, {
value: '1',
value: 1,
label: '省政策'
}, {
value: '2',
value: 2,
label: '市政策'
}, {
value: '3',
value: 3,
label: '区政策'
}],
contentDetail: '',
projectLabels: [],
value: '',
value1: '',
publishTime: ''
publishTime: '',
warning: {
title: '政策标题',
publishTime: '发布时间',
titleUrl: '原文链接',
imgUrl: '图片路径',
content: '原文内容',
pushDep: '发布部门',
intro: '政策简介'
}
}
},
computed: {
@ -453,6 +455,10 @@ export default {
},
methods: {
changePushDep(e) {
this.temp.pushDep = e
},
//
// handleChange(value) {
// this.temp.pushDep = value[value.length - 1]
@ -551,12 +557,15 @@ export default {
// i -= 1
// }
// }
// console.log(that.temp.publishTime)
const time1 = document.getElementById('TimeUpdate').value
var str = time1.replace(/-/g, '/')
that.temp.publishTime = str
console.log(time1)
console.log(this.$moment(that.temp.publishTime).format('YYYY-MM-DD'))
console.log(that.temp.publishTime)
that.temp.publishTime = that.temp.publishTime.replaceAll('/', '-')
// that.temp.pushDep = that.value
// that.temp.publishTime = this.$moment(that.temp.publishTime).format('YYYY-MM-DD')
// that.temp.projectLabels = this.value1
console.log('commit=========>', that.temp)
await api.PolicyUpdate(that.temp).then(res => {
this.getList()
@ -565,12 +574,18 @@ export default {
})
},
async handleModifyStatus(detail, num) {
console.log(detail)
this.listLoading = true
detail.auditStatus = num
await api.PolicyUpdate(detail).then(res => {
this.cascader = ''
this.listLoading = false
})
.catch(err => {
console.log(err)
this.listLoading = false
detail.auditStatus = 0
})
},
async handleDelete(id) {
await api.PolicyDelete(id).then(res => {
@ -582,26 +597,34 @@ export default {
for (const key in that.addPolicy) {
that.addPolicy[key] = ''
}
that.addPolicy.publishTime = new Date()
// that.addPolicy.publishTime = new Date()
that.dialogFormVisible1 = true
},
async CommitAdd() {
const that = this
that.addPolicy.pushDep = this.value
// that.addPolicy.pushDep = this.value
var Content = document.getElementById('Content')
var Time = document.getElementById('Time').value
that.addPolicy.content = Content.innerHTML
var str = Time.replace(/-/g, '/')
that.addPolicy.publishTime = str
for (const key in that.addPolicy) {
console.log(key)
if (that.addPolicy[key] === '') {
alert(key + '不能为空')
Message({
message: that.warning[key] + ' 不能为空',
type: 'error',
duration: 3 * 1000
})
return
}
}
console.log('CommitAdd', that.addPolicy)
api.PolicyAdd(that.addPolicy).then(res => {
this.value = ''
that.dialogFormVisible1 = false
this.getList()
})
}
// addLabel() {

Loading…
Cancel
Save