otherEdit.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <div class="app-container">
  3. <base-form ref="ruleForm" class="lib-edit" :data="formData" :is-inline="false" label-width="60px" :insertSlotArr="[1]">
  4. <div class="scoped-textarea" slot="OI1">
  5. <div class="st-top">
  6. <div class="t">资讯内容:</div>
  7. <div :class="isConShow ? 'r t2' : 'r'" @click="isConShow = !isConShow">{{isConShow ? '收起' : '展开'}}</div>
  8. </div>
  9. <div :class="isConShow ? 'st-content show' : 'st-content'">
  10. <div class="st-text">洪楼科技</div>
  11. <tinymce ref="refContent" v-model="content" :height="800" />
  12. </div>
  13. </div>
  14. </base-form>
  15. <div class="xl-form scoped-bottom">
  16. <el-button class="xl-form-btn t4" @click="openSI">从文中选封面图</el-button>
  17. <el-button class="xl-form-btn t1" @click="close('confirm')">保存</el-button>
  18. <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
  19. </div>
  20. <select-img
  21. :isShow="isSIShow"
  22. :imgTempArr="imgTempArr"
  23. @close="closeSI"
  24. />
  25. </div>
  26. </template>
  27. <script>
  28. import SelectImg from './components/popup/SelectImg'
  29. import Tinymce from '@/components/Tinymce'
  30. export default {
  31. components: { Tinymce, SelectImg },
  32. mixins,
  33. data() {
  34. return {
  35. formData: [],
  36. loading: true,
  37. cObj: {},
  38. content: '',
  39. isConShow: false,
  40. imgTempArr: [],
  41. isSIShow: false,
  42. }
  43. },
  44. created () {
  45. const query = this.$route.query
  46. if (query.id) {
  47. this.$api.house.admncplandetail({id: query.id}).then(res => {
  48. let curData = res || {}
  49. this.cObj = curData || {}
  50. this.content = curData.content || ''
  51. this.getDef()
  52. })
  53. } else {
  54. this.content = '<p>这里开始</p>\n<p>&nbsp;</p>\n<p style=\"margin: 10px 16px; padding: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; clear: both; min-height: 1em; color: #333333; font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif; font-size: 17px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: 0.544px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; line-height: 2em; text-indent: 2em; text-align: center;\"><span style=\"margin: 0px; padding: 0px; max-width: 100%; box-sizing: border-box !important; word-wrap: break-word !important; font-size: 16px;\"><span style=\"margin: 0px; padding: 0px; max-width: 100%; box-sizing: border-box !important; word-wrap: break-word !important; letter-spacing: 2px;\">-END-</span></span></p>\n<p><span style=\"margin: 0px; padding: 0px; max-width: 100%; box-sizing: border-box !important; word-wrap: break-word !important; color: #333333; font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; orphans: 2; text-align: justify; text-indent: 34px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; letter-spacing: 2px;\"><img class=\"wscnph\" src=\"https://img2.honglounews.com/20210603040359-8175.gif\" /></span></p>'
  55. this.getDef()
  56. }
  57. },
  58. methods: {
  59. getDef() {
  60. const params = { ...this.cObj }
  61. if (!params.author) params.author = '洪楼Plus'
  62. if (!params.hide_status) params.hide_status = '1'
  63. this.formData = [
  64. { label: '标题', key: 'title', rules: 1 },
  65. { label: '分类', key: 'plan_type', rules: 1, type: 'select', class: 'c-2', options: this.$dictData.plan_type, changeHandle: this.cateChange },
  66. { label: '作者', key: 'author', rules: 1, class: 'c-2' },
  67. { label: '时间', rules: 1, key: 'create_at', type: 'datePicker', class: 'c-2', type2: 'date'},
  68. { label: '状态', rules: 1, key: 'hide_status', type: 'select', class: 'c-2', options: this.$dictData.hide_status },
  69. { label: '封面', key: 'pri_image', rules: 1, type: 'cuImg',
  70. options: {
  71. w: 375,
  72. h: 262,
  73. }, class: 'c-2' },
  74. ]
  75. this.setDefaultValue(params)
  76. },
  77. cateChange (val) {
  78. // let params = {...this.$refs.ruleForm.baseForm}
  79. // let imgURL= ''
  80. // if (val === 'hlzt') imgURL= 'http://icon.honglounews.com/news_hlzt.jpg'
  81. // if (val === 'hljy' || val === 'xqsc') imgURL= 'http://icon.honglounews.com/news_hljy.jpg'
  82. // if (val === 'bkfx') imgURL= 'http://icon.honglounews.com/news_bkfx.jpg'
  83. // if (val === 'lppc') imgURL= 'http://icon.honglounews.com/news_lppc.jpg'
  84. // if (val === 'lpwd') imgURL= 'http://icon.honglounews.com/news_lpwd.jpg'
  85. // if (val === 'hlpd') imgURL= 'http://icon.honglounews.com/news_hlpd.jpg'
  86. // if (val === 'lszt') imgURL= 'http://icon.honglounews.com/news_lszt.jpg'
  87. // if (val === 'zcjd') imgURL= 'http://icon.honglounews.com/news_zcjd.jpg'
  88. // if (val === 'esf') imgURL= 'http://icon.honglounews.com/news_esf.jpg'
  89. // if (val === 'lsdt') imgURL= 'http://icon.honglounews.com/news_lsdt.jpg'
  90. // if (val === 'scfx') imgURL= 'http://icon.honglounews.com/news_scfx.jpg'
  91. // params.pri_image = imgURL
  92. // this.setDefaultValue(params)
  93. },
  94. fileChange (file) {
  95. let reader = new FileReader();
  96. let rs = reader.readAsArrayBuffer(file);
  97. let blob = null;
  98. reader.onload = (e) => {
  99. if (typeof e.target.result === 'object') {
  100. blob = new Blob([e.target.result])
  101. } else {
  102. blob = e.target.result
  103. }
  104. console.log(Object.prototype.toString.call(blob));
  105. }
  106. },
  107. openSI () {
  108. // let regex = new RegExp(/<img src="([^"]*?)" \/>/g)
  109. let regex = new RegExp(/src="https:\/\/img2.honglounews.com([^"]*?)(png|jpg)/g)
  110. let s = this.content.match(regex)
  111. if (!s) {
  112. this.$msgw('未找到图片,请先检查~')
  113. this.isConShow = true
  114. return
  115. }
  116. let imgTempArr = []
  117. for (var i = 0; i < s.length; i++) {
  118. // imgTempArr.push(s[i].replace(regex, '$1'))
  119. imgTempArr.push(s[i].replace('src="', ''))
  120. }
  121. // console.log(imgTempArr)
  122. this.imgTempArr = imgTempArr
  123. this.isSIShow = true
  124. },
  125. closeSI (str) {
  126. this.isSIShow = false
  127. if (str) {
  128. const oldform = this.$refs.ruleForm.baseForm
  129. this.setDefaultValue({...oldform, pri_image: str})
  130. }
  131. },
  132. close(str) {
  133. if (str === 'confirm') {
  134. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  135. if (valid) {
  136. const oldform = this.$refs.ruleForm.baseForm
  137. const newForm = { ...oldform }
  138. if (this.cObj.id) newForm.id = this.cObj.id
  139. if (newForm.estate_id_list && newForm.estate_id_list.length > 0) {
  140. newForm.estate_id_list = newForm.estate_id_list.join(',')
  141. } else {
  142. newForm.estate_id_list = ''
  143. }
  144. let apiStr = 'admncplanadd'
  145. if (newForm.id) apiStr = 'admncplanedit'
  146. if (this.content) {
  147. newForm.content = this.content
  148. } else {
  149. this.$msg('请输入资讯文章内容')
  150. return
  151. }
  152. newForm.news_type = 'adminadd'
  153. this.$api.house[apiStr](newForm).then(data => {
  154. this.$msgs(newForm.id ? '编辑成功' : '新增成功')
  155. this.$emit('close', newForm)
  156. this.$router.push('/news/other')
  157. })
  158. }
  159. })
  160. } else {
  161. this.$emit('close')
  162. this.$router.push('/news/other')
  163. this.setDefaultValue()
  164. }
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. @import '../../styles/libEdit.scss';
  171. .app-container {
  172. background: #f9f9f9;
  173. }
  174. .lib-edit {
  175. width: 900px;
  176. padding: 20px;
  177. margin: 0 auto;
  178. background: #fff;
  179. ::v-deep .el-form-item {
  180. margin-bottom: 10px;
  181. }
  182. ::v-deep .el-date-editor.el-input {
  183. width: 100%;
  184. }
  185. ::v-deep .img-upload {
  186. height: 180px;
  187. overflow: hidden;
  188. .icon {
  189. width: 280px;
  190. }
  191. .img {
  192. width: 280px;
  193. }
  194. }
  195. }
  196. .scoped-textarea {
  197. width: 100%;
  198. position: relative;
  199. .st-top {
  200. padding-bottom: 10px;
  201. user-select: none;
  202. .t {
  203. display: inline-block;
  204. vertical-align: middle;
  205. font-size: 14px;
  206. color: #2d8cf0;
  207. font-weight: bold;
  208. }
  209. .r {
  210. display: inline-block;
  211. vertical-align: middle;
  212. color: #fff;
  213. padding: 4px 10px;
  214. border-radius: 6px;
  215. background: #2d8cf0;
  216. font-weight: bold;
  217. font-size: 12px;
  218. cursor: pointer;
  219. &.t2 {
  220. background: #19be6b;
  221. }
  222. }
  223. }
  224. .st-content {
  225. height: 0;
  226. transition: 1s;
  227. overflow: hidden;
  228. .st-text {
  229. display: none;
  230. }
  231. &.show {
  232. height: 800px;
  233. .st-text {
  234. display: block;
  235. }
  236. }
  237. }
  238. .st-text {
  239. position: absolute;
  240. bottom: 1px;
  241. right: 14px;
  242. background: #fff;
  243. font-size: 12px;
  244. z-index: 9;
  245. height: 16px;
  246. line-height: 16px;
  247. padding-left: 10px;
  248. padding-right: 10px;
  249. color: #595959;
  250. user-select: none;
  251. }
  252. }
  253. .scoped-bottom {
  254. position: fixed;
  255. bottom: 0;
  256. right: 0;
  257. background: #fff;
  258. width: 100%;
  259. box-sizing: border-box;
  260. padding-left: 50%;
  261. padding-bottom: 20px;
  262. padding-top: 20px;
  263. border-top: 1px solid #dcdcdc;
  264. z-index: 10;
  265. }
  266. ::v-deep .el-drawer__body {
  267. padding-bottom: 30px;
  268. }
  269. </style>