edit.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <div class="inline-16">
  3. <el-button size="small" type="text" @click="onshow(drawer=true)">详情</el-button>
  4. <el-drawer
  5. title="编辑"
  6. :visible.sync="drawer"
  7. :with-header="false"
  8. direction="rtl"
  9. size="90%"
  10. append-to-body
  11. @close="drawer = false">
  12. <div class="detail__panel">
  13. <div class="container normal-panel normal-margin sticky">
  14. <el-button class="inline-16" v-if="edit" :disabled="form.status == '发布'" type="primary" size="small" @click="onEdit()" >编 辑</el-button>
  15. <p class="inline-16" v-if="save">编辑</p>
  16. <release class="inline-16" v-if="tool.checkAuth($route.name,'update') && status" :data="form" @onSuccess="onSuccess"></release>
  17. <topping class="inline-16" v-if="tool.checkAuth($route.name,'update') && status" :data="form" @onSuccess="onSuccess"></topping>
  18. <Del v-if="tool.checkAuth($route.name,'delete') && form.status == '新建'" @onSuccess="drawer=false,$router.push({path:'/notice_mag_list'})" :data="{sat_noticeid:$route.query.id}"/>
  19. <!-- <delete-btn :id="$route.query.id" nameId="20221101095103" nameKey="sat_noticeids" v-if="form.status == '新建'" type="detail" class="inline-16" @deleteSuccess="drawer=false"></delete-btn> -->
  20. </div>
  21. <div style="overflow-x:hidden">
  22. <el-row :gutter="16">
  23. <el-col :span="13">
  24. <div class="container normal-panel normal-margin">
  25. <p class="normal-title normal-margin">通告设置</p>
  26. <el-row :gutter="16">
  27. <el-form ref="form" :model="form" :rules="rules" label-width="80px" label-position="right" size="small" :disabled="edit">
  28. <el-col :span="24">
  29. <el-form-item label="标题" prop="title">
  30. <el-input v-model="form.title"></el-input>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="24">
  34. <el-form-item label="导语" prop="summary">
  35. <el-input v-model="form.summary"></el-input>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="8">
  39. <el-form-item label="板块" prop="sat_notice_classid">
  40. <el-select v-model="form.sat_notice_classid" placeholder="请选择">
  41. <el-option v-for="item in options" :key="item.sat_notice_classid" :label="item.classname"
  42. :value="item.sat_notice_classid">
  43. </el-option>
  44. </el-select>
  45. </el-form-item>
  46. </el-col>
  47. <el-col :span="8">
  48. <el-form-item label="生效日期" prop="begdate">
  49. <el-date-picker style="width:100%" v-model="form.begdate" value-format="yyyy-MM-dd" type="date"
  50. placeholder="生效日期">
  51. </el-date-picker>
  52. </el-form-item>
  53. </el-col>
  54. <el-col :span="8">
  55. <el-form-item label="截止日期" prop="enddate">
  56. <el-date-picker style="width:100%" v-model="form.enddate" value-format="yyyy-MM-dd" type="date"
  57. placeholder="截止日期">
  58. </el-date-picker>
  59. </el-form-item>
  60. </el-col>
  61. <el-col :span="24">
  62. <el-form-item label="是否置顶">
  63. <el-radio-group v-model="form.isontop">
  64. <el-radio :label="1">置顶</el-radio>
  65. <el-radio :label="0">不置顶</el-radio>
  66. </el-radio-group>
  67. </el-form-item>
  68. </el-col>
  69. <el-col :span="24">
  70. <el-form-item label="通告封面">
  71. <previewImage v-if="form.cover" style="width:256px" :image="image" :deletebtn="true"
  72. @onSuccess="clearCover"></previewImage>
  73. <upload v-else btntype="image" :folderid="folderid" accept=".JPG,.PNG"
  74. :bindData="{ ownertable: 'sat_notice', ownerid: form.sat_noticeid, usetype: 'cover' }"
  75. @onSuccess="onCoverSubmit"></upload>
  76. <p class="info">注:建议上传图片大小130x80像素,大小不超过2M,格式为JPG/PNG</p>
  77. </el-form-item>
  78. </el-col>
  79. </el-form>
  80. </el-row>
  81. </div>
  82. <div class="container normal-panel normal-margin">
  83. <attachmentList :attinfos="attinfo_video" @onSuccess="queryNoticeMain" :onlyread="store.state.pageOnlyRead" >
  84. <p slot="title">视频附件</p>
  85. <upload slot="upload" accept=".mp4,.ogg,.webm" :folderid="folderid"
  86. :bindData="{ ownertable: 'sat_notice', ownerid: form.sat_noticeid, usetype: 'default' }"
  87. @onSuccess="onUploadSuccess"></upload>
  88. </attachmentList>
  89. </div>
  90. <div class="container normal-panel normal-margin">
  91. <attachmentList :attinfos="attinfo_attachment" @onSuccess="queryNoticeMain" :onlyread="store.state.pageOnlyRead" >
  92. <upload slot="upload" :folderid="folderid"
  93. :bindData="{ ownertable: 'sat_notice', ownerid: form.sat_noticeid, usetype: 'default' }"
  94. @onSuccess="onUploadSuccess"></upload>
  95. </attachmentList>
  96. </div>
  97. <div class="container normal-panel normal-margin">
  98. <myEditor ref="editor" :content="form.content" :id="form.sat_noticeid" :disabled="!save"></myEditor>
  99. </div>
  100. </el-col>
  101. <el-col :span="11">
  102. <div class="container normal-panel normal-margin">
  103. <!-- <scopeOfauth :defaultData="defaultData" appidname="sat_noticeid" obiectName="sat_notice" :dataid="$route.query.id"
  104. @onChecked="onChecked"></scopeOfauth>-->
  105. <scopeOfauth :defaultData="defaultData" :disabled="form.status == '发布'" appidname="sat_noticeid" obiectName="sat_notice" :dataid="id"
  106. @onChecked="onChecked"></scopeOfauth>
  107. </div>
  108. </el-col>
  109. </el-row>
  110. </div>
  111. <!-- <router-view v-if = "drawer"/>-->
  112. </div>
  113. <div class="fixed__btn__panel" v-show="save">
  114. <el-button size="small" @click="onClose" class="normal-btn-width">取 消</el-button>
  115. <el-button size="small" type="warning" @click="onSubmit" class="normal-btn-width">保 存</el-button>
  116. </div>
  117. </el-drawer>
  118. </div>
  119. </template>
  120. <script>
  121. import upload from '@/components/upload/hw_obs_upload.vue'
  122. import previewImage from '@/components/previewImage/index.vue'
  123. import attachmentList from '@/components/attachment_list/index.vue'
  124. import scopeOfauth from '@/components/scopeOfAuthority/index.vue'
  125. import myEditor from '@/components/my-editor/Editor.vue'
  126. import store from '@/store'
  127. import release from './release'
  128. import topping from './tp.vue'
  129. import Del from './delete'
  130. export default {
  131. components: {
  132. upload,
  133. previewImage,
  134. attachmentList,
  135. scopeOfauth,
  136. myEditor,
  137. release,
  138. topping,
  139. Del
  140. },
  141. props:["id"],
  142. data() {
  143. var checkTime = (rule, value, callback) => {
  144. if (this.form.enddate) {
  145. if (new Date(value).getTime() > new Date(this.form.enddate).getTime()) {
  146. callback(new Error('生效日期不能大于截止日期'));
  147. } else {
  148. callback()
  149. }
  150. }
  151. };
  152. var checkTime2 = (rule, value, callback) => {
  153. if (this.form.begdate) {
  154. if (new Date(value).getTime() < new Date(this.form.begdate).getTime()) {
  155. callback(new Error('截止日期不能小于生效日期'));
  156. } else {
  157. callback()
  158. }
  159. }
  160. };
  161. return {
  162. store,
  163. edit:true,
  164. save:false,
  165. status:false,
  166. folderid: JSON.parse(sessionStorage.getItem('folderid')).appfolderid,
  167. rules: {
  168. title: [
  169. { required: true, message: '请输入课程名称', trigger: 'blur' },
  170. ],
  171. begdate: [
  172. { required: true, message: '请选择生效日期', trigger: 'change' },
  173. { required: true, validator: checkTime, trigger: 'change' },
  174. ],
  175. enddate: [
  176. { required: true, message: '请选择截止日期', trigger: 'change' },
  177. { required: true, validator: checkTime2, trigger: 'change' },
  178. ],
  179. sat_notice_classid: [
  180. { required: true, message: '请选择版块', trigger: 'change' }
  181. ],
  182. },
  183. form: {
  184. "title": "",
  185. "notes": "",
  186. "istextrequired": 1,
  187. "isattrequired": 1,
  188. "onceonly": 1,
  189. "sat_submiteditmodelid": "0",
  190. "begdate": "",
  191. "enddate": "",
  192. "issecret": false
  193. },
  194. defaultData: {},
  195. image: {},
  196. authData: {},
  197. attinfo_video: [],
  198. attinfo_attachment: [],
  199. options: [],
  200. drawer:false
  201. }
  202. },
  203. watch: {
  204. drawer (val) {
  205. if(!val) {
  206. this.save =false
  207. this.edit = true
  208. }
  209. },
  210. edit (val) {
  211. if(val) {
  212. this.$store.dispatch('pageOnlyRead',true)
  213. } else {
  214. this.$store.dispatch('pageOnlyRead',false)
  215. }
  216. }
  217. },
  218. methods: {
  219. onUploadSuccess() {
  220. this.form.status !== '新建' ? this.queryNoticeMain() : this.onSubmit()
  221. },
  222. onSubmit() {
  223. this.$refs['form'].validate(async (valid) => {
  224. if (!valid) return false;
  225. this.form.content = this.$refs.editor.html
  226. const res = await this.$api.requested({
  227. "id": "20221101094803",
  228. "method": "insertormodify_notice",
  229. "content": this.form
  230. })
  231. this.tool.showMessage(res,() => {
  232. this.edit = true
  233. this.save = false
  234. this.insertCoursewareauth()
  235. this.queryNoticeMain()
  236. this.$emit("updateSuccess")
  237. })
  238. });
  239. },
  240. //通告详情
  241. async queryNoticeMain() {
  242. const res = await this.$api.requested({
  243. "id": "20221101095003",
  244. // "method": "queryNoticeMain",
  245. "content": {
  246. "sat_noticeid": this.id
  247. }
  248. })
  249. this.attinfo_video = res.data.attinfos.filter(e => {
  250. if (e.postfix === 'mp4' || e.postfix === 'ogg' || e.postfix === 'webm') {
  251. return e
  252. }
  253. })
  254. this.attinfo_attachment = res.data.attinfos.filter(e => {
  255. if (e.postfix !== 'mp4' && e.postfix !== 'ogg' && e.postfix !== 'webm') {
  256. return e
  257. }
  258. })
  259. this.form = Object.assign({}, this.form, res.data)
  260. this.form.status !== '新建'?this.$store.dispatch('pageOnlyRead',true):this.$store.dispatch('pageOnlyRead',false)
  261. if(!this.save) {
  262. this.$store.dispatch('pageOnlyRead',true)
  263. } else {
  264. this.$store.dispatch('pageOnlyRead',false)
  265. }
  266. this.queryFileLink()
  267. this.queryNoticeClass()
  268. console.log("获取通告详细数据")
  269. console.log(this.form)
  270. this.status = true
  271. },
  272. // 通告板块
  273. async queryNoticeClass() {
  274. const res = await this.$api.requested({
  275. "id": "20221101094603",
  276. "content": {
  277. "pageNumber": 1,
  278. "pageSize": 1000,
  279. "where": {
  280. "condition": ""
  281. }
  282. }
  283. })
  284. console.log("板块")
  285. console.log(res)
  286. this.options = res.data
  287. this.form.sat_notice_classid = res.data[0].sat_notice_classid
  288. },
  289. // 获取封面信息
  290. async queryFileLink() {
  291. this.dialogEditVisible = true
  292. const res = await this.$api.requested({
  293. "classname": "system.attachment.Attachment",
  294. "method": "queryFileLink",
  295. "content": {
  296. "ownertable": 'sat_notice',
  297. "ownerid": this.form.sat_noticeid,
  298. "usetype": 'cover'//传空返回有所
  299. }
  300. })
  301. console.log("封面信息")
  302. console.log(res)
  303. this.image = res.data[0]
  304. console.log("获取封面")
  305. console.log(this.image)
  306. /*res.data[0] ? this.image = res.data[0].url : this.image = { url: '' }*/
  307. },
  308. onCoverSubmit(res) {
  309. this.form.cover = JSON.parse(res.attinfos).data[0].url
  310. this.image = JSON.parse(res.attinfos).data[0]
  311. },
  312. clearCover() {
  313. this.form.cover = null
  314. this.image = {}
  315. },
  316. // 获取保存授权范围数据
  317. onChecked(param) {
  318. this.authData = param
  319. },
  320. // 新增授权范围
  321. async insertCoursewareauth() {
  322. const res = await this.$api.requested({
  323. // "classname": "webmanage.saletool.notice.noticeauth",
  324. // "method": "createNoticeAuth",
  325. "id":20221101142003,
  326. "content": this.authData
  327. })
  328. console.log("新增")
  329. res.code === 0 ? this.$notify({
  330. title: '失败',
  331. message: res.data,
  332. type: 'error'
  333. }) : ''
  334. },
  335. // 查询授权信息
  336. async query_auth() {
  337. const res = await this.$api.requested({
  338. "id":20221101142303,
  339. "content": {
  340. "sat_noticeid": this.id,
  341. }
  342. })
  343. console.log("查询授权")
  344. this.defaultData = res.data
  345. },
  346. onshow(){
  347. this.$router.replace({path:'notice_mag_list',query:{id:this.id}})
  348. this.queryNoticeMain()
  349. this.query_auth()
  350. this.edit = true
  351. this.save = false
  352. },
  353. onEdit(){
  354. this.edit = false
  355. this.save = true
  356. },
  357. handleCommand(command){
  358. console.log(command)
  359. if (command === 'analysis'){
  360. this.dataAnalysis()
  361. }else if(command === 'release'){
  362. }
  363. },
  364. dataAnalysis(){
  365. console.log("数据分析")
  366. this.$router.push({path:'notice_analysis',query:{id:this.id}})
  367. },
  368. onSuccess(){
  369. this.drawer = false
  370. this.$emit("updateSuccess")
  371. },
  372. onClose(){
  373. this.save = false
  374. this.edit = true
  375. }
  376. },
  377. mounted() {
  378. this.status = false
  379. }
  380. }
  381. </script>
  382. <style>
  383. .detail__panel{
  384. background:#f1f2f3;
  385. overflow-y: scroll;
  386. font-size: 14px;
  387. color:#666;
  388. height:100vh;
  389. }
  390. </style>