edit_notice.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div>
  3. <div class="container normal-panel normal-margin sticky">
  4. <el-button :disabled="store.state.pageOnlyRead" type="warning" size="small" icon="el-icon-s-claim" @click="onSubmit((res)=>tool.showMessage(res))" :loading="store.state.loading">保 存</el-button>
  5. </div>
  6. <div style="overflow-x:hidden">
  7. <el-row :gutter="16">
  8. <el-col :span="13">
  9. <div class="container normal-panel normal-margin">
  10. <p class="normal-title normal-margin">通告设置</p>
  11. <el-row :gutter="16">
  12. <el-form ref="form" :model="form" :rules="rules" label-width="80px" label-position="left" size="small">
  13. <el-col :span="24">
  14. <el-form-item label="标题" prop="title">
  15. <el-input v-model="form.title"></el-input>
  16. </el-form-item>
  17. </el-col>
  18. <el-col :span="24">
  19. <el-form-item label="导语" prop="summary">
  20. <el-input v-model="form.summary"></el-input>
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="8">
  24. <el-form-item label="板块" prop="sat_notice_classid">
  25. <el-select v-model="form.sat_notice_classid" placeholder="请选择">
  26. <el-option v-for="item in options" :key="item.sat_notice_classid" :label="item.classname"
  27. :value="item.sat_notice_classid">
  28. </el-option>
  29. </el-select>
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="8">
  33. <el-form-item label="生效日期" prop="begdate">
  34. <el-date-picker style="width:100%" v-model="form.begdate" value-format="yyyy-MM-dd" type="date"
  35. placeholder="生效日期">
  36. </el-date-picker>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="8">
  40. <el-form-item label="截止日期" prop="enddate">
  41. <el-date-picker style="width:100%" v-model="form.enddate" value-format="yyyy-MM-dd" type="date"
  42. placeholder="截止日期">
  43. </el-date-picker>
  44. </el-form-item>
  45. </el-col>
  46. <el-col :span="24">
  47. <el-form-item label="是否置顶">
  48. <el-radio-group v-model="form.isontop">
  49. <el-radio :label="1">置顶</el-radio>
  50. <el-radio :label="0">不置顶</el-radio>
  51. </el-radio-group>
  52. </el-form-item>
  53. </el-col>
  54. <el-col :span="24">
  55. <el-form-item label="通告封面">
  56. <previewImage v-if="form.cover" style="width:256px" :image="image" :deletebtn="true"
  57. @onSuccess="clearCover"></previewImage>
  58. <upload v-else btntype="image" :folderid="folderid" accept=".JPG,.PNG"
  59. :bindData="{ ownertable: 'sat_notice', ownerid: form.sat_noticeid, usetype: 'cover' }"
  60. @onSuccess="onCoverSubmit"></upload>
  61. <p class="info">注:建议上传图片大小130x80像素,大小不超过2M,格式为JPG/PNG</p>
  62. </el-form-item>
  63. </el-col>
  64. </el-form>
  65. </el-row>
  66. </div>
  67. <div class="container normal-panel normal-margin">
  68. <attachmentList :attinfos="attinfo_video" @onSuccess="queryNoticeMain" :onlyread="store.state.pageOnlyRead">
  69. <p slot="title">视频附件</p>
  70. <upload slot="upload" accept=".mp4,.ogg,.webm" :folderid="folderid"
  71. :bindData="{ ownertable: 'sat_notice', ownerid: form.sat_noticeid, usetype: 'default' }"
  72. @onSuccess="onUploadSuccess"></upload>
  73. </attachmentList>
  74. </div>
  75. <div class="container normal-panel normal-margin">
  76. <attachmentList :attinfos="attinfo_attachment" @onSuccess="queryNoticeMain" :onlyread="store.state.pageOnlyRead">
  77. <upload slot="upload" :folderid="folderid"
  78. :bindData="{ ownertable: 'sat_notice', ownerid: form.sat_noticeid, usetype: 'default' }"
  79. @onSuccess="onUploadSuccess"></upload>
  80. </attachmentList>
  81. </div>
  82. <div class="container normal-panel normal-margin">
  83. <myEditor ref="editor" :content="form.content" :id="form.sat_noticeid"></myEditor>
  84. </div>
  85. </el-col>
  86. <el-col :span="11">
  87. <div class="container normal-panel normal-margin">
  88. <scopeOfauth :defaultData="defaultData" appidname="sat_noticeid" obiectName="sat_notice" :dataid="$route.query.id"
  89. @onChecked="onChecked"></scopeOfauth>
  90. </div>
  91. </el-col>
  92. </el-row>
  93. </div>
  94. </div>
  95. </template>
  96. <script>
  97. import upload from '@/components/upload/hw_obs_upload.vue'
  98. import previewImage from '@/components/previewImage/index.vue'
  99. import attachmentList from '@/components/attachment_list/index.vue'
  100. import scopeOfauth from '@/components/scopeOfAuthority/index.vue'
  101. import myEditor from '@/components/my-editor/Editor.vue'
  102. import store from '@/store'
  103. export default {
  104. components: {
  105. upload,
  106. previewImage,
  107. attachmentList,
  108. scopeOfauth,
  109. myEditor
  110. },
  111. data() {
  112. return {
  113. store,
  114. folderid: JSON.parse(sessionStorage.getItem('folderid')).appfolderid,
  115. rules: {
  116. title: [
  117. { required: true, message: '请输入课程名称', trigger: 'blur' },
  118. ],
  119. begdate: [
  120. { required: true, message: '请选择生效日期', trigger: 'change' }
  121. ],
  122. enddate: [
  123. { required: true, message: '请选择截止日期', trigger: 'change' }
  124. ],
  125. sat_notice_classid: [
  126. { required: true, message: '请选择版块', trigger: 'change' }
  127. ],
  128. summary: [
  129. { required: true, message: '请输入导语', trigger: 'blur' },
  130. ],
  131. },
  132. form: {
  133. "title": "",
  134. "notes": "",
  135. "istextrequired": 1,
  136. "isattrequired": 1,
  137. "onceonly": 1,
  138. "sat_submiteditmodelid": "0",
  139. "begdate": "",
  140. "enddate": "",
  141. "issecret": false
  142. },
  143. defaultData: {},
  144. image: {},
  145. authData: {},
  146. attinfo_video: [],
  147. attinfo_attachment: [],
  148. options: [],
  149. }
  150. },
  151. methods: {
  152. onUploadSuccess() {
  153. this.form.status !== '新建' ? this.queryNoticeMain() : this.onSubmit()
  154. },
  155. onSubmit(callbcak) {
  156. this.$refs['form'].validate(async (valid) => {
  157. if (!valid) return false;
  158. this.form.content = this.$refs.editor.html
  159. const res = await this.$api.requested({
  160. "classname": "webmanage.saletool.notice.notice",
  161. "method": "insertormodify_notice",
  162. "content": this.form
  163. })
  164. callbcak?callbcak(res):''
  165. this.insertCoursewareauth()
  166. this.queryNoticeMain()
  167. });
  168. },
  169. //通告详情
  170. async queryNoticeMain() {
  171. const res = await this.$api.requested({
  172. "classname": "webmanage.saletool.notice.notice",
  173. "method": "queryNoticeMain",
  174. "content": {
  175. "sat_noticeid": this.$route.query.id
  176. }
  177. })
  178. this.attinfo_video = res.data.attinfos.filter(e => {
  179. if (e.postfix === 'mp4' || e.postfix === 'ogg' || e.postfix === 'webm') {
  180. return e
  181. }
  182. })
  183. this.attinfo_attachment = res.data.attinfos.filter(e => {
  184. if (e.postfix !== 'mp4' && e.postfix !== 'ogg' && e.postfix !== 'webm') {
  185. return e
  186. }
  187. })
  188. this.form = Object.assign({}, this.form, res.data)
  189. this.form.status !== '新建'?this.$store.dispatch('pageOnlyRead',true):this.$store.dispatch('pageOnlyRead',false)
  190. this.queryFileLink()
  191. this.queryNoticeClass()
  192. },
  193. // 通告板块
  194. async queryNoticeClass() {
  195. const res = await this.$api.requested({
  196. "classname": "webmanage.saletool.notice.noticeclass",
  197. "method": "queryNoticeClass",
  198. "content": {
  199. "pageNumber": 1,
  200. "pageSize": 1000,
  201. "where": {
  202. "condition": ""
  203. }
  204. }
  205. })
  206. this.options = res.data
  207. // this.form.sat_notice_classid = res.data[0].sat_notice_classid
  208. },
  209. // 获取封面信息
  210. async queryFileLink() {
  211. this.dialogEditVisible = true
  212. const res = await this.$api.requested({
  213. "classname": "system.attachment.Attachment",
  214. "method": "queryFileLink",
  215. "content": {
  216. "ownertable": 'sat_notice',
  217. "ownerid": this.form.sat_noticeid,
  218. "usetype": 'cover'//传空返回有所
  219. }
  220. })
  221. res.data[0] ? this.image = res.data[0] : this.image = { url: '' }
  222. },
  223. onCoverSubmit(res) {
  224. this.form.cover = JSON.parse(res.attinfos).data[0].url
  225. this.image = JSON.parse(res.attinfos).data[0]
  226. },
  227. clearCover() {
  228. this.form.cover = null
  229. this.image = {}
  230. },
  231. // 获取保存授权范围数据
  232. onChecked(param) {
  233. this.authData = param
  234. },
  235. // 新增授权范围
  236. async insertCoursewareauth() {
  237. const res = await this.$api.requested({
  238. "classname": "webmanage.saletool.notice.noticeauth",
  239. "method": "createNoticeAuth",
  240. "content": this.authData
  241. })
  242. res.code === 0 ? this.$notify({
  243. title: '失败',
  244. message: res.data,
  245. type: 'error'
  246. }) : ''
  247. },
  248. // 查询授权信息
  249. async query_auth() {
  250. const res = await this.$api.requested({
  251. "classname": "webmanage.saletool.notice.noticeauth",
  252. "method": "queryNoticeAuth",
  253. "content": {
  254. "sat_noticeid": this.$route.query.id,
  255. }
  256. })
  257. this.defaultData = res.data
  258. },
  259. },
  260. mounted() {
  261. this.queryNoticeMain()
  262. this.query_auth()
  263. }
  264. }
  265. </script>
  266. <style>
  267. </style>