add.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <template>
  2. <view >
  3. <view class="bgtop"></view>
  4. <uni-forms :modelValue="datainfo">
  5. <view class="addbox">
  6. <view class="boxs">
  7. <view class="tips">
  8. <image :src="tipimg"></image>
  9. <view>请于填写信息前认真核对信息是否有误</view>
  10. </view>
  11. <view class="pdbox">
  12. <view class="titbox mb14">
  13. <view class="tit flexc">
  14. <image :src="titimg"></image>
  15. <view>个人信息</view>
  16. </view>
  17. </view>
  18. <view class="titinf">
  19. <view class="txt"><text>上报者:</text>{{datainfo.sqmyName}}</view>
  20. <view class="txt"><text>联系方式:</text>{{datainfo.sqmyPhone}}</view>
  21. <view class="txt"><text>联系地址:</text>{{datainfo.address}}</view>
  22. </view>
  23. <image :src="infobg" class="infobg"></image>
  24. </view>
  25. </view>
  26. <view class="boxs pdbox" style="padding-bottom: 2rpx;">
  27. <view class="titbox mb14">
  28. <view class="tit flexc">
  29. <image :src="titimg"></image>
  30. <view>基本详情</view>
  31. </view>
  32. </view>
  33. <view class="pb8">
  34. <uni-forms-item label="信息标题" name="title" required>
  35. <uni-easyinput :inputBorder="false" type="text" v-model="datainfo.title" placeholder="请输入信息标题" />
  36. <view class="edtip pa">* 标题前无须加关于,标题后无须加的建议,系统将自动填写</view>
  37. </uni-forms-item>
  38. </view>
  39. <!-- <uni-forms-item label="主题类型" name="categoryName" required>
  40. <view class="openbox" :class="datainfo.categoryName?'':'coa'" @click="gettalbFn">{{datainfo.categoryName||"请选择主题类型"}}</view>
  41. </uni-forms-item> -->
  42. <picker range-key='label' :value="ztlxidx" :range="ztlxlist" @change='bindDateChangea'>
  43. <uni-forms-item label="主题类型" name="topicType" required>
  44. <view class="lbtabp">
  45. <view v-if="datainfo.topicType&&!ztlxtxt">{{statusFormat(datainfo.topicType,ztlxlist,'ztlx')}}</view>
  46. <view v-else :class="ztlxtxt?'':'coa'">{{ztlxtxt||"请选择主题类型"}}</view>
  47. </view>
  48. </uni-forms-item>
  49. </picker>
  50. <!-- <uni-forms-item label="联系人" name="lxrName" required>
  51. <uni-easyinput :inputBorder="false" type="text" v-model="datainfo.lxrName" placeholder="请输入联系人" />
  52. </uni-forms-item>
  53. <uni-forms-item label="联系人联系方式" name="lxrPhone" required>
  54. <uni-easyinput :inputBorder="false" type="number" v-model="datainfo.lxrPhone" placeholder="请输入联系人联系方式" />
  55. </uni-forms-item> -->
  56. </view>
  57. <view class="boxs pdbox">
  58. <view class="titbox mb14 flexc">
  59. <view class="tit flexc flex1">
  60. <image :src="titimg"></image>
  61. <view>信息内容</view>
  62. </view>
  63. <view class="titr" @click="getPaiFn">一键排版</view>
  64. </view>
  65. <editor id="editor" :class="pbFlag?'pbbox':''" class="ql-container" placeholder="请输入信息内容" show-img-size show-img-toolbar
  66. show-img-resize @statuschange="onStatusChange" :read-only="readOnly" @ready="onEditorReady">
  67. </editor>
  68. <view class="edtip flext mb24 mt14"><text>*</text>信息内容输入完毕后,可点击右上角“一键排版”按钮进行快速排版</view>
  69. </view>
  70. <view class="boxs pdbox">
  71. <view class="titbox mb14">
  72. <view class="tit flexc">
  73. <image :src="titimg"></image>
  74. <view>附件内容</view>
  75. </view>
  76. </view>
  77. <view class="flexcj mb10">
  78. <view class="fw f15 co34">添加附件</view>
  79. <view class="fjadd"><lsj-upload
  80. ref="lsjUpload"
  81. childId="upload1"
  82. :width="width"
  83. :height="height"
  84. :option="option"
  85. :size="size"
  86. :formats="formats"
  87. :debug="debug"
  88. :instantly="instantly"
  89. @progress=""
  90. @uploadEnd="onuploadEnd" >
  91. <view class="btn" :style="{width: width,height: height}">上传附件</view>
  92. </lsj-upload>
  93. </view>
  94. </view>
  95. <view class="ptb12" v-if="filelist&&filelist.length">
  96. <view class="fjlists" v-for="(ite,idx) in filelist" :key='idx'>
  97. <view class="flext" @click="getDown(ite.url)">
  98. <view class="imgl"><image :src="fjimg" ></image></view>
  99. <view class="tit">{{ite.name}}</view>
  100. </view>
  101. <!-- 删除 -->
  102. <view class="delimg flex0" @click.stop="getDelFj(idx)">
  103. <image :src="delimg"></image>
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. <view class="boxs pdbox" style="padding-bottom: 2rpx;">
  109. <view class="titbox mb14">
  110. <view class="tit flexc">
  111. <image :src="titimg"></image>
  112. <view>更多信息</view>
  113. </view>
  114. </view>
  115. <uni-forms-item label="是否公开" name="isPublicity">
  116. <view class="checkbox">
  117. <uni-data-checkbox v-model="datainfo.isPublicity" :localdata="sfList" />
  118. </view>
  119. </uni-forms-item>
  120. <uni-forms-item label="是否涉密" name="isSecret">
  121. <view class="checkbox">
  122. <uni-data-checkbox v-model="datainfo.isSecret" :localdata="sfList" />
  123. </view>
  124. </uni-forms-item>
  125. </view>
  126. <view class="addbtn">
  127. <view class="btn btn1" @click="getZanFnt">暂存</view>
  128. <view class="btn btn2" @click="getSubmit">提交</view>
  129. </view>
  130. </view>
  131. </uni-forms>
  132. </view>
  133. </template>
  134. <script>
  135. import config from '@/config'
  136. const baseUrl = config.baseUrl
  137. import { getToken } from '@/utils/auth'
  138. import { selectValue,selectValueKey } from '@/utils/common.js';
  139. import {getsqmyInfoAddFn,getsqmyInfoDetailFn,getsqmyInfoEditFn} from "@/api/mine/sqmyInfo.js"
  140. import {getDictionaryFn} from "@/api/mine/register.js"
  141. export default{
  142. data(){
  143. return{
  144. //附件
  145. option: {
  146. // 上传服务器地址,需要替换为你的接口地址
  147. url: baseUrl+'/common/upload', // 该地址非真实路径,需替换为你项目自己的接口地址
  148. // 上传附件的key
  149. name: 'file',
  150. // 根据你接口需求自定义请求头,默认不要写content-type,让浏览器自适配
  151. header: {
  152. // 示例参数可删除
  153. 'Authorization': 'Bearer ' + getToken(),
  154. },
  155. // 根据你接口需求自定义body参数
  156. formData: {}
  157. },
  158. // 选择文件后是否立即自动上传,true=选择后立即上传
  159. instantly: true,
  160. // 必传宽高且宽高应与slot宽高保持一致
  161. width: '',
  162. height: '48rpx',
  163. // 限制允许上传的格式,空串=不限制,默认为空
  164. formats: 'doc,docx,xls,xlsx,ppt,txt,pdf,zip,rar,word,png,jpg,jpeg',
  165. // 文件上传大小限制
  166. size: 100,
  167. // 文件数量限制 默认10
  168. count: 5,
  169. // 文件回显列表
  170. files: new Map(),
  171. // 微信小程序Map对象for循环不显示,所以转成普通数组,不要问为什么,我也不知道
  172. wxFiles: [],
  173. // 是否打印日志
  174. debug: false,
  175. filelist:[],
  176. pbFlag:false,
  177. readOnly:false,
  178. fjimg:require("@/work/static/images/fjimg.png"),
  179. delimg:require("@/work/static/images/delimg.png"),
  180. tipimg:require("@/work/static/images/tip.png"),
  181. titimg:require("@/work/static/images/titbg.png"),
  182. infobg:require("@/work/static/images/infobg.png"),
  183. datainfo:{
  184. "sqmyUserId":this.$store.state.user.userId,//提案人ID
  185. "title":"",//标题
  186. "topicType":"",//主题类型1:经济建设类,2:政治建设类,3:文化建设类,4:社会建设类,5:生态文明建设类,6:其他
  187. "sqmyName":this.$store.state.user.memberInfo.name,//
  188. "sqmyPhone":this.$store.state.user.memberInfo.phonenumber,//
  189. "address":this.$store.state.user.memberInfo.address,//
  190. "unit":this.$store.state.user.memberInfo.unit,//
  191. // "lxrName":"",//
  192. // "lxrPhone":"",//
  193. "sqmyContent":"",//内容
  194. "isPublicity":"0",//同意公开(0是 1否)
  195. "isSecret":"1",//是否涉密(0是 1否)
  196. "zxFjList":[]
  197. },
  198. ztlxidx:'',
  199. ztlxtxt:'',
  200. sfList:[{text: '是',value: '0'},{text: '否',value: '1'}],
  201. ztlxlist:[],
  202. editorCtx:'',
  203. tary:'',
  204. id:"",
  205. pagetype:'add',
  206. editinfo:'',
  207. }
  208. },
  209. onUnload(){
  210. uni.$off('refreshtalb')
  211. uni.$off('refreshtary')
  212. },
  213. onLoad(e) {
  214. uni.$on('refreshtalb', (e) => {
  215. this.datainfo.categoryName=e.categoryName
  216. this.datainfo.categoryId=e.categoryId
  217. })
  218. uni.$on('refreshtary', (e) => {
  219. this.datainfo.proposalUserList=e.proposalUserList;
  220. this.tary=e.namelist.join('/')
  221. })
  222. this.init()
  223. if(e.type=='edit'){
  224. this.id=e.id;
  225. this.pagetype='edit'
  226. this.getDetail()
  227. }
  228. if(e.type=='old'&&uni.getStorageSync('sqmyList')){
  229. var newObj=JSON.parse(JSON.stringify(uni.getStorageSync('sqmyList')))
  230. var params=newObj.params;
  231. this.datainfo=params;
  232. this.editinfo=params.sqmyContent;
  233. if(params.zxFjList&&params.zxFjList.length){
  234. this.filelist=JSON.parse(JSON.stringify(params.zxFjList))
  235. }
  236. }
  237. },
  238. methods:{
  239. kayType(ite,list){
  240. return selectValue(list, ite);
  241. },
  242. statusFormat(ite,list,type) {
  243. var aite=selectValueKey(list, ite);
  244. if(type=='ztlx'){
  245. this.ztlxidx=aite.key
  246. }
  247. return aite.actions;
  248. },
  249. init(){
  250. // 主题类型
  251. getDictionaryFn('sqmy_topic_type').then(res=>{
  252. if(res.code==200&&res.data.length){
  253. this.ztlxlist = res.data.map(v => {
  254. return {
  255. label: v.dictLabel,
  256. value: v.dictValue
  257. }
  258. })
  259. }
  260. })
  261. // 界别circles
  262. // getDictionaryFn('circles').then(res=>{
  263. // if(res.code==200&&res.data.length){
  264. // this.jblist = res.data.map(v => {
  265. // return {
  266. // label: v.dictLabel,
  267. // value: v.dictValue
  268. // }
  269. // })
  270. // }
  271. // })
  272. // 党派
  273. // getDictionaryFn('political_parties').then(res=>{
  274. // if(res.code==200&&res.data.length){
  275. // this.dplist = res.data.map(v => {
  276. // return {
  277. // label: v.dictLabel,
  278. // value: v.dictValue
  279. // }
  280. // })
  281. // }
  282. // })
  283. },
  284. bindDateChangea(e){
  285. var val=e.detail.value;
  286. this.ztlxtxt=this.ztlxlist[val].label;
  287. this.datainfo.topicType=this.ztlxlist[val].value;
  288. },
  289. getDetail(){
  290. var that=this;
  291. getsqmyInfoDetailFn(this.id).then(res=>{
  292. if(res.code==200){
  293. var data=res.data;
  294. this.datainfo=res.data;
  295. if(data.zxFjList&&data.zxFjList.length){
  296. this.filelist=JSON.parse(JSON.stringify(data.zxFjList))
  297. }
  298. this.editinfo=data.sqmyContent;
  299. uni.createSelectorQuery().select('#editor').context(function(res) {
  300. that.editorCtx = res.context;
  301. that.editorCtx.setContents({
  302. html:data.sqmyContent
  303. })
  304. }).exec();
  305. }
  306. })
  307. },
  308. getCheck(id){
  309. var idx=this.checkidx.indexOf(id)
  310. if(idx!=-1){
  311. this.checkidx.splice(idx,1)
  312. }else{
  313. this.checkidx.push(id)
  314. }
  315. },
  316. getPaiFn(){
  317. this.pbFlag=true;
  318. },
  319. gettalbFn(){
  320. var obj={
  321. id:this.datainfo.categoryId,
  322. name:this.datainfo.categoryName,
  323. }
  324. this.$tab.navigateTo('/work/pages/case/talbclass?data='+encodeURIComponent(JSON.stringify(obj)))
  325. },
  326. getlmtaFn(){
  327. var obj={
  328. list:this.datainfo.proposalUserList
  329. }
  330. this.$tab.navigateTo('/work/pages/case/lmtapeople?data='+encodeURIComponent(JSON.stringify(obj)))
  331. },
  332. // 暂存
  333. getZanFnt(){
  334. var that=this;
  335. that.editorCtx.getContents({
  336. success: function(data) {
  337. var params=that.datainfo;
  338. params.sqmyContent=data.html;
  339. var obj={
  340. params:params,
  341. }
  342. uni.setStorageSync('sqmyList', JSON.parse(JSON.stringify(obj)))
  343. that.$toast("暂存成功")
  344. }
  345. })
  346. },
  347. getSubmit(){
  348. var that=this;
  349. if(!this.datainfo.title){
  350. this.$toast("请输入信息标题")
  351. return
  352. }
  353. if(!this.datainfo.topicType){
  354. this.$toast("请选择主题类型")
  355. return
  356. }
  357. // if(!this.datainfo.lxrName){
  358. // this.$toast("请输入联系人姓名")
  359. // return
  360. // }
  361. // if(!this.datainfo.lxrPhone){
  362. // this.$toast("请输入联系人手机号")
  363. // return
  364. // }
  365. // if(this.datainfo.lxrPhone){
  366. // let regphone = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
  367. // if (this.datainfo.lxrPhone && !regphone.test(this.datainfo.lxrPhone)) {
  368. // that.$toast("请输入正确的手机号")
  369. // return
  370. // }
  371. // }
  372. var sqmyContent='';
  373. that.editorCtx.getContents({
  374. success: function(data) {
  375. var params=that.datainfo;
  376. params.sqmyContent=data.html;
  377. if(that.pagetype=='add'){
  378. getsqmyInfoAddFn(params).then(res=>{
  379. if(res.code==200){
  380. uni.removeStorageSync('sqmyList')
  381. that.$toast("提交成功")
  382. uni.$emit("refreshlist")
  383. setTimeout(function(){
  384. uni.navigateBack({
  385. delta: 1 //返回层数,2则上上页
  386. });
  387. },1200)
  388. }
  389. })
  390. }else{
  391. getsqmyInfoEditFn(params).then(res=>{
  392. if(res.code==200){
  393. that.$toast("修改成功")
  394. uni.$emit("refreshdetail")
  395. setTimeout(function(){
  396. uni.navigateBack({
  397. delta: 1 //返回层数,2则上上页
  398. });
  399. },1200)
  400. }
  401. })
  402. }
  403. }
  404. })
  405. },
  406. onuploadEnd(item) {
  407. var newobj={}
  408. var responseText=JSON.parse(item.responseText)
  409. newobj.name=responseText.originalFilename;
  410. newobj.url=responseText.fileName;
  411. this.filelist.push(newobj)
  412. this.datainfo.zxFjList=JSON.parse(JSON.stringify(this.filelist))
  413. },
  414. getDelFj(idx){
  415. var that=this;
  416. uni.showModal({
  417. title: '确认删除',
  418. content: "是否确认删除",
  419. cancelText: '取消',
  420. confirmText: '确认',
  421. success: function(res) {
  422. if (res.confirm) {
  423. that.filelist.splice(idx,1)
  424. that.datainfo.zxFjList=JSON.parse(JSON.stringify(that.filelist))
  425. } else if (res.cancel) {
  426. }
  427. }
  428. });
  429. },
  430. getDown(e){
  431. uni.showLoading({
  432. title: '加载中'
  433. });
  434. var url=baseUrl+e;
  435. uni.downloadFile({
  436. url: url,//文件的下载路径
  437. success(result) {
  438. uni.hideLoading()
  439. var filePath = result.tempFilePath;
  440. uni.openDocument({
  441. filePath: filePath,
  442. showMenu: true,
  443. success: function (res) {
  444. // console.log('打开文档成功');
  445. }
  446. });
  447. },
  448. fail(res) {uni.hideLoading()}
  449. })
  450. },
  451. onStatusChange(){
  452. },
  453. onEditorReady(){
  454. var that=this;
  455. uni.createSelectorQuery().select('#editor').context(function(res) {
  456. that.editorCtx = res.context;
  457. that.editorCtx.setContents({
  458. html:that.editinfo
  459. })
  460. }).exec();
  461. }
  462. }
  463. }
  464. </script>
  465. <style scoped lang="scss">
  466. .bgtop{height: 150rpx;background-color: $com-cd3;width: 100%;}
  467. .pdbox{padding: 34rpx 24rpx 16rpx;}
  468. .addbox /deep/ .uni-forms-item{margin-bottom:36rpx;}
  469. .addbox /deep/ .uni-easyinput{flex: 1;text-align: right;font-size: 30rpx;}
  470. .addbox /deep/ .uni-forms-item__label{font-weight: bold;font-size: 30rpx;color: #343434;width: 198rpx !important;padding-left:20rpx;}
  471. .addbox /deep/ .is-required{position: absolute;left: 0;top: 50%;margin-top: -10rpx;}
  472. .addbox /deep/ .uni-data-checklist{display: flex;align-items: center;justify-content: flex-end;}
  473. .addbox /deep/ .uni-easyinput__placeholder-class{font-weight: 500;font-size: 30rpx;color: #AAAAAA;}
  474. .addbox /deep/ .checklist-box{margin-right: 0 !important;margin-left: 40rpx !important;}
  475. .fjadd{
  476. .btn{font-weight: bold;font-size: 30rpx;color: #1D64E2;margin: 0;display: flex;align-items: center;}
  477. }
  478. .addbox{margin-top: -120rpx;
  479. padding: 0 24rpx 50rpx;
  480. .boxs{background: #FFFFFF;border-radius: 30rpx;margin-bottom: 24rpx;overflow: hidden;position: relative;
  481. .infobg{width: 102rpx;height: 106rpx;position: absolute;right: 26rpx;bottom: 22rpx;}
  482. .tips{background: #F1F6FF;padding: 18rpx 38rpx;display: flex;align-items: flex-start;
  483. image{width: 20rpx;height: 26rpx;margin-right: 16rpx;flex:0 0 auto;margin-top: 4rpx;}
  484. view{font-weight: 500;font-size: 26rpx;color: #1D64E2;}
  485. }
  486. .titbox{
  487. .tit{
  488. image{width: 32rpx;height: 18rpx;margin-right: 10rpx;}
  489. view{font-weight: bold;font-size: 32rpx;color: #222327;}
  490. }
  491. .titr{width: 146rpx;height: 50rpx;background: #E4EEFF;border-radius: 26rpx;font-weight: 500;font-size: 24rpx;color: #1D64E2;text-align: center;line-height: 50rpx;}
  492. }
  493. .titinf{display: flex;flex-wrap: wrap;
  494. .txt{font-weight: 500;font-size: 28rpx;margin-bottom: 18rpx;flex:0 1 auto;min-width: 50%;display: flex;align-items: flex-start;color: #222327;
  495. text{flex: 0 0 auto;color: #9F9F9F;}
  496. }
  497. }
  498. .openbox{display: flex;align-items: center;justify-content: flex-end;font-weight: 500;
  499. font-size: 30rpx;height: 100%;color: #222327;
  500. }
  501. .edtip{font-weight: 500;font-size: 22rpx;color: #FF0000;
  502. text{margin: 4rpx 8rpx 0 0;}
  503. &.pa{position: absolute;right: 0;bottom: -15px;text-align: right;width: 702rpx;}
  504. }
  505. }
  506. }
  507. .matab{display: flex;align-items: center;flex-wrap: nowrap;overflow: auto;position: absolute;left: 0;right: -48rpx;
  508. .list{min-width:112rpx;height: 50rpx;background: #ffffff;border-radius: 25rpx;font-size: 30rpx;font-weight: 500;box-sizing: border-box;
  509. color: #AAAAAA;padding: 0 24rpx;box-sizing: border-box;margin-left:24rpx;flex: 0 0 auto;border: 2rpx solid #C1C1C1;display: flex;align-items: center;justify-content: center;
  510. &.act{background: #E4EEFF;color: #1D64E2;border: none;}
  511. }
  512. }
  513. // 附件
  514. .fjlists {display: flex;align-items: flex-start;justify-content: space-between;margin-bottom: 12rpx;
  515. image{margin-right: 18rpx;flex: 0 0 auto;}
  516. .imgl{width: 40rpx;height: 40rpx;display: flex;align-items: center;justify-content: center;margin-right: 16rpx;
  517. image{width: 26rpx;height: 24rpx;}
  518. }
  519. .tit{font-size: 26rpx;color: #343434;font-weight: 500;margin-top: 4rpx;}
  520. .delimg{width: 40rpx;height:40rpx;margin-left: 16rpx;display: flex;align-items: center;justify-content: center;
  521. image{width: 26rpx;height: 26rpx;}
  522. }
  523. }
  524. // 按钮
  525. .addbtn{display: flex;align-items: center;justify-content: space-between;padding-top: 26rpx;
  526. .btn{width: 336rpx;height: 80rpx;font-weight: bold;font-size: 30rpx;box-sizing: border-box;border-radius: 40rpx;display: flex;align-items: center;justify-content: center;
  527. &.btn1{border: 2rpx solid #1D64E2;background: #ffffff;color: #1D64E2;}
  528. &.btn2{background: #1D64E2;color: #ffffff;}
  529. }
  530. }
  531. .addbox /deep/ .pbbox .ql-editor p{text-indent: 2rem;}
  532. </style>