add.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  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.unit}}</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" >
  51. <uni-easyinput :inputBorder="false" type="text" v-model="datainfo.lxrName" placeholder="请输入联系人" />
  52. </uni-forms-item>
  53. <uni-forms-item label="联系人联系方式" name="lxrPhone" >
  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. "unit":this.$store.state.user.memberInfo.unit,//
  190. "lxrName":"",//
  191. "lxrPhone":"",//
  192. "sqmyContent":"",//内容
  193. "isPublicity":"0",//同意公开(0是 1否)
  194. "isSecret":"1",//是否涉密(0是 1否)
  195. "zxFjList":[]
  196. },
  197. ztlxidx:'',
  198. ztlxtxt:'',
  199. sfList:[{text: '是',value: '0'},{text: '否',value: '1'}],
  200. ztlxlist:[],
  201. editorCtx:'',
  202. tary:'',
  203. id:"",
  204. pagetype:'add',
  205. editinfo:'',
  206. }
  207. },
  208. onUnload(){
  209. uni.$off('refreshtalb')
  210. uni.$off('refreshtary')
  211. },
  212. onLoad(e) {
  213. uni.$on('refreshtalb', (e) => {
  214. this.datainfo.categoryName=e.categoryName
  215. this.datainfo.categoryId=e.categoryId
  216. })
  217. uni.$on('refreshtary', (e) => {
  218. this.datainfo.proposalUserList=e.proposalUserList;
  219. this.tary=e.namelist.join('/')
  220. })
  221. this.init()
  222. if(e.type=='edit'){
  223. this.id=e.id;
  224. this.pagetype='edit'
  225. this.getDetail()
  226. }
  227. if(e.type=='old'&&uni.getStorageSync('sqmyList')){
  228. var newObj=JSON.parse(JSON.stringify(uni.getStorageSync('sqmyList')))
  229. var params=newObj.params;
  230. this.datainfo=params;
  231. this.editinfo=params.sqmyContent;
  232. if(params.zxFjList&&params.zxFjList.length){
  233. this.filelist=JSON.parse(JSON.stringify(params.zxFjList))
  234. }
  235. }
  236. },
  237. methods:{
  238. kayType(ite,list){
  239. return selectValue(list, ite);
  240. },
  241. statusFormat(ite,list,type) {
  242. var aite=selectValueKey(list, ite);
  243. if(type=='ztlx'){
  244. this.ztlxidx=aite.key
  245. }
  246. return aite.actions;
  247. },
  248. init(){
  249. // 主题类型
  250. getDictionaryFn('sqmy_topic_type').then(res=>{
  251. if(res.code==200&&res.data.length){
  252. this.ztlxlist = res.data.map(v => {
  253. return {
  254. label: v.dictLabel,
  255. value: v.dictValue
  256. }
  257. })
  258. }
  259. })
  260. // 界别circles
  261. // getDictionaryFn('circles').then(res=>{
  262. // if(res.code==200&&res.data.length){
  263. // this.jblist = res.data.map(v => {
  264. // return {
  265. // label: v.dictLabel,
  266. // value: v.dictValue
  267. // }
  268. // })
  269. // }
  270. // })
  271. // 党派
  272. // getDictionaryFn('political_parties').then(res=>{
  273. // if(res.code==200&&res.data.length){
  274. // this.dplist = res.data.map(v => {
  275. // return {
  276. // label: v.dictLabel,
  277. // value: v.dictValue
  278. // }
  279. // })
  280. // }
  281. // })
  282. },
  283. bindDateChangea(e){
  284. var val=e.detail.value;
  285. this.ztlxtxt=this.ztlxlist[val].label;
  286. this.datainfo.topicType=this.ztlxlist[val].value;
  287. },
  288. getDetail(){
  289. var that=this;
  290. getsqmyInfoDetailFn(this.id).then(res=>{
  291. if(res.code==200){
  292. var data=res.data;
  293. this.datainfo=res.data;
  294. if(data.zxFjList&&data.zxFjList.length){
  295. this.filelist=JSON.parse(JSON.stringify(data.zxFjList))
  296. }
  297. this.editinfo=data.sqmyContent;
  298. var taryList=data.proposalUserList;
  299. if(taryList&&taryList.length){
  300. var newArr=[]
  301. taryList.forEach(ite=>{
  302. newArr.push(ite.name)
  303. })
  304. this.tary=newArr.join('/')
  305. }
  306. that.checkidx=data.negotiateType.split(',')
  307. // this.dwdetList=res.data.proposalUnitReplyList;
  308. }
  309. })
  310. },
  311. getCheck(id){
  312. var idx=this.checkidx.indexOf(id)
  313. if(idx!=-1){
  314. this.checkidx.splice(idx,1)
  315. }else{
  316. this.checkidx.push(id)
  317. }
  318. },
  319. getPaiFn(){
  320. this.pbFlag=true;
  321. },
  322. gettalbFn(){
  323. var obj={
  324. id:this.datainfo.categoryId,
  325. name:this.datainfo.categoryName,
  326. }
  327. this.$tab.navigateTo('/work/pages/case/talbclass?data='+encodeURIComponent(JSON.stringify(obj)))
  328. },
  329. getlmtaFn(){
  330. var obj={
  331. list:this.datainfo.proposalUserList
  332. }
  333. this.$tab.navigateTo('/work/pages/case/lmtapeople?data='+encodeURIComponent(JSON.stringify(obj)))
  334. },
  335. // 暂存
  336. getZanFnt(){
  337. var that=this;
  338. that.editorCtx.getContents({
  339. success: function(data) {
  340. var params=that.datainfo;
  341. params.sqmyContent=data.html;
  342. var obj={
  343. params:params,
  344. }
  345. uni.setStorageSync('sqmyList', JSON.parse(JSON.stringify(obj)))
  346. that.$toast("暂存成功")
  347. }
  348. })
  349. },
  350. getSubmit(){
  351. var that=this;
  352. if(!this.datainfo.title){
  353. this.$toast("请输入标题")
  354. return
  355. }
  356. if(!this.datainfo.topicType){
  357. this.$toast("请选择提案类别")
  358. return
  359. }
  360. // if(!this.datainfo.lxrName){
  361. // this.$toast("请输入联系人姓名")
  362. // return
  363. // }
  364. // if(!this.datainfo.lxrPhone){
  365. // this.$toast("请输入联系人手机号")
  366. // return
  367. // }
  368. if(this.datainfo.lxrPhone){
  369. 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}$/
  370. if (this.datainfo.lxrPhone && !regphone.test(this.datainfo.lxrPhone)) {
  371. that.$toast("请输入正确的手机号")
  372. return
  373. }
  374. }
  375. var sqmyContent='';
  376. that.editorCtx.getContents({
  377. success: function(data) {
  378. var params=that.datainfo;
  379. params.sqmyContent=data.html;
  380. if(that.pagetype=='add'){
  381. getsqmyInfoAddFn(params).then(res=>{
  382. if(res.code==200){
  383. uni.removeStorageSync('sqmyList')
  384. that.$toast("提交成功")
  385. uni.$emit("refreshlist")
  386. setTimeout(function(){
  387. uni.navigateBack({
  388. delta: 1 //返回层数,2则上上页
  389. });
  390. },1200)
  391. }
  392. })
  393. }else{
  394. getsqmyInfoEditFn(params).then(res=>{
  395. if(res.code==200){
  396. that.$toast("修改成功")
  397. uni.$emit("refreshdetail")
  398. setTimeout(function(){
  399. uni.navigateBack({
  400. delta: 1 //返回层数,2则上上页
  401. });
  402. },1200)
  403. }
  404. })
  405. }
  406. }
  407. })
  408. },
  409. onuploadEnd(item) {
  410. var newobj={}
  411. var responseText=JSON.parse(item.responseText)
  412. newobj.name=responseText.originalFilename;
  413. newobj.url=responseText.fileName;
  414. this.filelist.push(newobj)
  415. this.datainfo.zxFjList=JSON.parse(JSON.stringify(this.filelist))
  416. },
  417. getDelFj(idx){
  418. var that=this;
  419. uni.showModal({
  420. title: '确认删除',
  421. content: "是否确认删除",
  422. cancelText: '取消',
  423. confirmText: '确认',
  424. success: function(res) {
  425. if (res.confirm) {
  426. that.filelist.splice(idx,1)
  427. that.datainfo.zxFjList=JSON.parse(JSON.stringify(that.filelist))
  428. } else if (res.cancel) {
  429. }
  430. }
  431. });
  432. },
  433. getDown(e){
  434. uni.showLoading({
  435. title: '加载中'
  436. });
  437. var url=baseUrl+e;
  438. uni.downloadFile({
  439. url: url,//文件的下载路径
  440. success(result) {
  441. uni.hideLoading()
  442. var filePath = result.tempFilePath;
  443. uni.openDocument({
  444. filePath: filePath,
  445. showMenu: true,
  446. success: function (res) {
  447. // console.log('打开文档成功');
  448. }
  449. });
  450. },
  451. fail(res) {uni.hideLoading()}
  452. })
  453. },
  454. onStatusChange(){
  455. },
  456. onEditorReady(){
  457. var that=this;
  458. uni.createSelectorQuery().select('#editor').context(function(res) {
  459. that.editorCtx = res.context;
  460. that.editorCtx.setContents({
  461. html:that.editinfo
  462. })
  463. }).exec();
  464. }
  465. }
  466. }
  467. </script>
  468. <style scoped lang="scss">
  469. .bgtop{height: 150rpx;background-color: $com-cd3;width: 100%;}
  470. .pdbox{padding: 34rpx 24rpx 16rpx;}
  471. .addbox /deep/ .uni-forms-item{margin-bottom:36rpx;}
  472. .addbox /deep/ .uni-easyinput{flex: 1;text-align: right;font-size: 30rpx;}
  473. .addbox /deep/ .uni-forms-item__label{font-weight: bold;font-size: 30rpx;color: #343434;width: 198rpx !important;padding-left:20rpx;}
  474. .addbox /deep/ .is-required{position: absolute;left: 0;top: 50%;margin-top: -10rpx;}
  475. .addbox /deep/ .uni-data-checklist{display: flex;align-items: center;justify-content: flex-end;}
  476. .addbox /deep/ .uni-easyinput__placeholder-class{font-weight: 500;font-size: 30rpx;color: #AAAAAA;}
  477. .addbox /deep/ .checklist-box{margin-right: 0 !important;margin-left: 40rpx !important;}
  478. .fjadd{
  479. .btn{font-weight: bold;font-size: 30rpx;color: #1D64E2;margin: 0;display: flex;align-items: center;}
  480. }
  481. .addbox{margin-top: -120rpx;
  482. padding: 0 24rpx 50rpx;
  483. .boxs{background: #FFFFFF;border-radius: 30rpx;margin-bottom: 24rpx;overflow: hidden;position: relative;
  484. .infobg{width: 102rpx;height: 106rpx;position: absolute;right: 26rpx;bottom: 22rpx;}
  485. .tips{background: #F1F6FF;padding: 18rpx 38rpx;display: flex;align-items: flex-start;
  486. image{width: 20rpx;height: 26rpx;margin-right: 16rpx;flex:0 0 auto;margin-top: 4rpx;}
  487. view{font-weight: 500;font-size: 26rpx;color: #1D64E2;}
  488. }
  489. .titbox{
  490. .tit{
  491. image{width: 32rpx;height: 18rpx;margin-right: 10rpx;}
  492. view{font-weight: bold;font-size: 32rpx;color: #222327;}
  493. }
  494. .titr{width: 146rpx;height: 50rpx;background: #E4EEFF;border-radius: 26rpx;font-weight: 500;font-size: 24rpx;color: #1D64E2;text-align: center;line-height: 50rpx;}
  495. }
  496. .titinf{display: flex;flex-wrap: wrap;
  497. .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;
  498. text{flex: 0 0 auto;color: #9F9F9F;}
  499. }
  500. }
  501. .openbox{display: flex;align-items: center;justify-content: flex-end;font-weight: 500;
  502. font-size: 30rpx;height: 100%;color: #222327;
  503. }
  504. .edtip{font-weight: 500;font-size: 22rpx;color: #FF0000;
  505. text{margin: 4rpx 8rpx 0 0;}
  506. &.pa{position: absolute;right: 0;bottom: -15px;text-align: right;width: 702rpx;}
  507. }
  508. }
  509. }
  510. .matab{display: flex;align-items: center;flex-wrap: nowrap;overflow: auto;position: absolute;left: 0;right: -48rpx;
  511. .list{min-width:112rpx;height: 50rpx;background: #ffffff;border-radius: 25rpx;font-size: 30rpx;font-weight: 500;box-sizing: border-box;
  512. 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;
  513. &.act{background: #E4EEFF;color: #1D64E2;border: none;}
  514. }
  515. }
  516. // 附件
  517. .fjlists {display: flex;align-items: flex-start;justify-content: space-between;margin-bottom: 12rpx;
  518. image{margin-right: 18rpx;flex: 0 0 auto;}
  519. .imgl{width: 40rpx;height: 40rpx;display: flex;align-items: center;justify-content: center;margin-right: 16rpx;
  520. image{width: 26rpx;height: 24rpx;}
  521. }
  522. .tit{font-size: 26rpx;color: #343434;font-weight: 500;margin-top: 4rpx;}
  523. .delimg{width: 40rpx;height:40rpx;margin-left: 16rpx;display: flex;align-items: center;justify-content: center;
  524. image{width: 26rpx;height: 26rpx;}
  525. }
  526. }
  527. // 按钮
  528. .addbtn{display: flex;align-items: center;justify-content: space-between;padding-top: 26rpx;
  529. .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;
  530. &.btn1{border: 2rpx solid #1D64E2;background: #ffffff;color: #1D64E2;}
  531. &.btn2{background: #1D64E2;color: #ffffff;}
  532. }
  533. }
  534. .addbox /deep/ .pbbox .ql-editor p{text-indent: 2rem;}
  535. </style>