questionAdd.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-blue" :isBack="true" v-if="title == '问题诉求情况'">
  4. <block slot="backText">返回</block>
  5. <block slot="content">问题诉求情况</block>
  6. </cu-custom>
  7. <form @submit="formSubmit" class="cu-list menu">
  8. <view class="titlebg2">
  9. <view class="titlet1" ></view>
  10. <view class="titlet2" >企业信息</view>
  11. </view>
  12. <view class="textbg">
  13. <view class="text12">
  14. 企业名称
  15. </view>
  16. <view class="text22">
  17. {{inputForm.name}}
  18. </view>
  19. </view>
  20. <view class="textbg">
  21. <view class="text12">
  22. 属地
  23. </view>
  24. <view class="text22">
  25. {{inputForm.qySd}}
  26. </view>
  27. </view>
  28. <view class="textbg">
  29. <view class="text12">
  30. 企业负责人
  31. </view>
  32. <view class="text22">
  33. {{inputForm.lxr}}
  34. </view>
  35. </view>
  36. <view class="textbg">
  37. <view class="text12">
  38. 负责人号码
  39. </view>
  40. <view class="text22">
  41. {{inputForm.phone}}
  42. </view>
  43. </view>
  44. <view style="height: 30rpx;background-color: white;"></view>
  45. <view class="titlebg2" style="margin-top:10rpx ;">
  46. <view class="titlet1" ></view>
  47. <view class="titlet2" >挂钩干部</view>
  48. </view>
  49. <view class="textbg">
  50. <view class="text12">
  51. 姓名
  52. </view>
  53. <view class="text22">
  54. {{inputForm.des14}}
  55. </view>
  56. </view>
  57. <view style="height: 30rpx;background-color: white;"></view>
  58. <view class="titlebg2" style="margin-top:10rpx ;">
  59. <view class="titlet1" ></view>
  60. <view class="titlet2" >主要问题诉求</view>
  61. </view>
  62. <view v-for="(item, index2) in questionList">
  63. <view style="display: flex;background-color: #ffffff;justify-content: space-between; align-items: center;">
  64. <view class="titlebb">
  65. 问题{{index2+1}}
  66. </view>
  67. <icon v-if="index2!=0&&canedit" @click="del(index2)" type="cancel" style="padding-right: 15rpx;padding-top: 5rpx;padding-left: 100rpx;"></icon>
  68. </view>
  69. <view class="input1">
  70. <view class="title">
  71. 问题名称
  72. </view>
  73. <input v-model="item.qname" placeholder="请填写问题名称" :disabled="!canedit"></input>
  74. </view>
  75. <view class="cu-form-group margin-top">
  76. <view class="title">
  77. 问题类型
  78. </view>
  79. <picker v-if="canedit" class="title2" @change="bindPickerChange($event, index2)" :value="index" :range="parkList">
  80. <view class="input2">{{item.qtype||'请选择问题类型'}}</view>
  81. </picker>
  82. <view v-if="!canedit" class="input2">{{item.qtype||'请选择问题类型'}}</view>
  83. </view>
  84. <view class="cu-form-group margin-top" v-if="item.t1!=''">
  85. <view class="title">
  86. {{item.t1}}
  87. </view>
  88. <input style="width: 200rpx;" v-model="item.gaps" :placeholder="item.t1s" :disabled="!canedit"></input>{{item.t1d}}
  89. </view>
  90. <view class="cu-form-group margin-top" >
  91. <view class="title">
  92. 问题描述
  93. </view>
  94. <textarea v-model="item.des" placeholder="请填写问题描述" :disabled="!canedit" ></textarea>
  95. </view>
  96. <view class="cu-form-group margin-top" style="border-bottom: 3px solid #eee;">
  97. <view class="title">
  98. 涉及单位
  99. </view>
  100. <zqs-select
  101. class="input2"
  102. :multiple="true"
  103. :list="pickerData"
  104. label-key="label"
  105. value-key="value"
  106. placeholder=" 请选择"
  107. title="请选择涉及单位"
  108. clearable
  109. v-model="item.checkUserList"
  110. @search="searchEvent"
  111. @change="selectChange2"
  112. ></zqs-select>
  113. </view>
  114. </view>
  115. <view style="width: 400rpx;margin-left: 20rpx;">
  116. <button v-if="canedit" @click="addp" style="height: 30px;" class="cu-btn block bg-blue margin-tb-sm lg">+增加问题</button>
  117. </view>
  118. <view style="height: 40rpx;"></view>
  119. <view class="flexC" v-if="canedit">
  120. <button @click="save" class="bt1 block margin-tb-sm lg">暂存</button>
  121. <button form-type="submit" class="bt1 cu-btn block bg-blue margin-tb-sm lg">提交</button>
  122. </view>
  123. <view style="height: 40rpx;"></view>
  124. </form>
  125. </view>
  126. </template>
  127. <script>
  128. var graceChecker = require("@/common/graceChecker.js");
  129. import revenueListService from '@/api/revenue/revenueListService'
  130. import loginService from '@/api/auth/loginService.js'
  131. export default {
  132. computed: {
  133. // 动态计算选中的 label
  134. selectedLabels() {
  135. return this.item.checkUserList
  136. .map((value) => {
  137. const item = this.pickerData.find((option) => option.value === value);
  138. return item ? item.label : value; // 如果找不到,返回 value
  139. })
  140. .join(", ");
  141. },
  142. },
  143. onShow() {
  144. this.$auth.checkLogin()
  145. loginService.getDictList({
  146. dictTypeId:"1907700775364263937"
  147. }).then(({data}) => {
  148. this.pickerData = data
  149. this.pickerDataOld = data
  150. //默认第一个选项
  151. //this.checkUserList=this.pickerData[0].value;
  152. }).catch(e => {
  153. })
  154. },
  155. data() {
  156. return {
  157. title: '问题诉求情况',
  158. inputForm: {
  159. id:'',
  160. name: '',
  161. qySd: '',
  162. lxr: '',
  163. phone: '',
  164. bz5: '',
  165. des14:'',
  166. },
  167. t1: '可供产品',
  168. t1s: '请填写可供产品',
  169. t2: '可供数量',
  170. t2s: '请填写可供数量',
  171. t3: '详细描述',
  172. t3s: '请填写详细描述',
  173. autoUpload: false,
  174. picLists: [],
  175. picUrl: [],
  176. imageStyles: {
  177. width: 90,
  178. height: 90
  179. },
  180. parkList: [ "用工人才", "资金需求", "土地厂房", "订单及配套", "政策兑现", "创新及品牌", "审批手续", "水电气供应", "安全环保消防", "其他(需详细说明)"],
  181. questionList:[{qname:"",qtype:"",qTypeindex:"",gaps:"",des:"",t1:"",t1s:"",checkUserList:[]}],
  182. index:0,
  183. ischeck: false,
  184. canedit:true,
  185. pickerData: [],
  186. pickerDataOld: []
  187. }
  188. },
  189. created() {
  190. },
  191. mounted() {
  192. },
  193. async onLoad(query) {
  194. if(query.ischeck!=undefined&&query.ischeck=='1'){
  195. //查看
  196. this.ischeck=true;
  197. let data2 = await loginService.getdzfQuestionqueryById({id:query.id})
  198. this.inputForm.id = data2.data.id;
  199. this.inputForm.name = data2.data.qyName;
  200. this.inputForm.qySd = data2.data.qySd;
  201. this.inputForm.lxr = data2.data.qyFzr;
  202. this.inputForm.phone = data2.data.phone;
  203. this.inputForm.des14 = data2.data.officer;
  204. for (let i = 0; i < data2.data.dzfQuestionDetilDTOList.length; i++) {
  205. data2.data.dzfQuestionDetilDTOList[i].checkUserList=[];
  206. if (data2.data.dzfQuestionDetilDTOList[i].des7 != ''&&data2.data.dzfQuestionDetilDTOList[i].des7 != undefined) {
  207. data2.data.dzfQuestionDetilDTOList[i].checkUserList=data2.data.dzfQuestionDetilDTOList[i].des7.split(",");
  208. }
  209. }
  210. this.questionList=data2.data.dzfQuestionDetilDTOList;
  211. //不是暂存时不可以修改
  212. if(data2.data.states!='0'){
  213. this.canedit=false;
  214. }
  215. }else{
  216. //新增
  217. let data2 = await loginService.queryByUserName()
  218. this.inputForm = this.recover(this.inputForm, data2.data)
  219. this.inputForm.qySd = data2.data.des1;
  220. this.inputForm.id="";
  221. }
  222. },
  223. methods: {
  224. //交办单位
  225. selectChange2() {
  226. // 此处为点击的事件
  227. this.pickerData=this.pickerDataOld;
  228. },
  229. searchEvent(val) {
  230. this.pickerData=this.filteredItems(val);
  231. },
  232. filteredItems(searchQuery) {
  233. const query = searchQuery.trim();
  234. if (!query) return this.pickerDataOld;
  235. return this.pickerDataOld.filter(item => {
  236. return item.label.toString().includes(query);
  237. });
  238. },
  239. //交办单位结束
  240. addp(){
  241. this.questionList.push({qname:"",qtype:"",qTypeindex:"",gaps:"",des:"",t1:"",t1s:"",checkUserList:[]})
  242. },
  243. del(index2){
  244. this.questionList.splice(index2, 1);
  245. },
  246. bindPickerChange: function(e,index2) {
  247. if(e.detail.value==0){
  248. this.questionList[index2].t1='缺口数';
  249. this.questionList[index2].t1s= '请填写缺口数';
  250. this.questionList[index2].t1d= '人';
  251. }else if(e.detail.value==1){
  252. this.questionList[index2].t1='缺口数';
  253. this.questionList[index2].t1s= '请填写缺口数';
  254. this.questionList[index2].t1d= '万元';
  255. }else if(e.detail.value==2){
  256. this.questionList[index2].t1='缺口数';
  257. this.questionList[index2].t1s= '请填写缺口数';
  258. this.questionList[index2].t1d= '';
  259. }else{
  260. this.questionList[index2].t1='';
  261. this.questionList[index2].t1s= '';
  262. this.questionList[index2].t1d= '';
  263. }
  264. this.questionList[index2].qTypeindex = e.detail.value;
  265. this.questionList[index2].qtype=this.parkList[e.detail.value]
  266. },
  267. // 获取上传进度
  268. progress(e) {
  269. console.log('上传进度:', e)
  270. },
  271. // 上传成功
  272. success(e) {
  273. console.log('上传成功')
  274. },
  275. // 上传失败
  276. fail(e) {
  277. console.log('上传失败:', e)
  278. },
  279. deleteFile(e) {
  280. this.picUrl.splice(e.index, 1)
  281. },
  282. // 获取上传状态
  283. select(e) {
  284. console.log('选择文件:', e)
  285. var _this = this
  286. var i = 0
  287. upload()
  288. function upload() {
  289. if (i >= e.tempFiles.length) {
  290. return;
  291. }
  292. var item = e.tempFiles[i]
  293. uni.showLoading({
  294. title: "上传中",
  295. mask: true
  296. });
  297. uni.uploadFile({
  298. url: '/yd_qycpfb/file/upload?uploadPath=userdir', // 仅为示例,非真实的接口地址
  299. filePath: item.url,
  300. name: 'file',
  301. formData: {
  302. 'fileName': item.name
  303. },
  304. header: {
  305. 'token': _this.$auth.getUserToken()
  306. },
  307. success: (res) => {
  308. var data = res.data
  309. if (typeof data['error'] != "undefined") {
  310. uni.showToast({
  311. icon: 'none',
  312. title: '上传失败,请联系开发!'
  313. });
  314. _this.$refs.picFile.clearFiles(_this.picLists.length)
  315. } else {
  316. _this.picUrl.push({
  317. url: data,
  318. uuid: item.uuid
  319. })
  320. i++;
  321. upload()
  322. }
  323. },
  324. fail: () => {
  325. uni.hideLoading();
  326. uni.showToast({
  327. icon: 'none',
  328. title: '上传失败,请联系开发!'
  329. });
  330. _this.$refs.picFile.clearFiles(_this.picLists.length)
  331. },
  332. complete: function() {
  333. uni.hideLoading();
  334. }
  335. });
  336. }
  337. },
  338. save(){
  339. this.inputForm.des10="";
  340. this.getJBBM();
  341. this.inputForm.dzfQuestionDetilDTOList=this.questionList;
  342. this.checkinput();
  343. },
  344. formSubmit: function(e) {
  345. this.inputForm.des10="submit";
  346. this.getJBBM();
  347. this.inputForm.dzfQuestionDetilDTOList=this.questionList;
  348. this.checkinput();
  349. },
  350. getJBBM(){
  351. //将交办单位的名称带出
  352. for (let i = 0; i < this.questionList.length; i++) {
  353. if (this.questionList[i].checkUserList != []) {
  354. this.questionList[i].checkUserListName=this.questionList[i].checkUserList.map((value) => {
  355. const item = this.pickerData.find((option) => option.value === value);
  356. return item ? item.label : value; // 如果找不到,返回 value
  357. })
  358. .join(",");
  359. }
  360. this.questionList[i].checkUserList=this.questionList[i].checkUserList.join(",");
  361. }
  362. },
  363. checkinput(){
  364. if(this.hasDuplicateQName(this.questionList)){
  365. uni.showToast({
  366. icon: 'none',
  367. title: '问题名称不能重复!'
  368. });
  369. }else{
  370. uni.showLoading()
  371. loginService.saveQuestion(this.inputForm).then(({
  372. data
  373. }) => {
  374. uni.hideLoading();
  375. uni.showToast({
  376. title: "问题诉求提交成功!",
  377. icon: "success"
  378. });
  379. uni.navigateTo({
  380. url: '/pages/question/questionList'
  381. })
  382. }).catch((e) => {
  383. uni.hideLoading();
  384. })
  385. }
  386. },
  387. hasDuplicateQName(array) {
  388. const seen = new Set();
  389. for (const item of array) {
  390. if (seen.has(item.qname)) {
  391. return true; // 找到重复的 qName
  392. }
  393. seen.add(item.qname);
  394. }
  395. return false; // 没有重复的 qName
  396. }
  397. }
  398. }
  399. </script>
  400. <style>
  401. /* .file-title) {
  402. font-size: 17px !important;
  403. } */
  404. input,textarea{
  405. color: #8799a3;
  406. }
  407. .input1{
  408. background-color: #ffffff;
  409. padding: 1upx 40upx;
  410. display: flex;
  411. align-items: center;
  412. padding-top: 20upx;
  413. border-bottom: 1px solid #eee;
  414. }
  415. .input1 .title {
  416. text-align: justify;
  417. padding-right: 30upx;
  418. font-size: 30upx;
  419. position: relative;
  420. height: 60upx;
  421. line-height: 60upx;
  422. border: ;
  423. }
  424. .title2{
  425. width: 75%;
  426. text-align: left;
  427. }
  428. .input2 {
  429. flex: 1;
  430. font-size: 30upx;
  431. color: #555;
  432. padding-right: 20upx;
  433. width: 500rpx;
  434. }
  435. .uni-input{
  436. }
  437. .textbg{
  438. display: flex;
  439. background-color: white;
  440. padding-top: 29rpx;
  441. }
  442. .text12{
  443. width: 200rpx;
  444. margin-left: 30rpx;
  445. color: #000000;
  446. font-size: 29rpx;
  447. }
  448. .text2{
  449. flex: 1;
  450. color: #000000;
  451. font-size: 30rpx;
  452. padding-bottom: 2rpx;
  453. }
  454. .text22{
  455. flex: 1;
  456. color: #666666;
  457. font-size: 29rpx;
  458. padding-bottom: 2rpx;
  459. align-self: flex-end;
  460. }
  461. .titlebg2{
  462. display: flex;
  463. background-color: white;
  464. padding-left: 22rpx;
  465. padding-top: 35rpx;
  466. padding-bottom: 25rpx;
  467. margin-bottom: 2rpx;
  468. }
  469. .titlet1{
  470. width: 7rpx;
  471. margin-top: 7rpx;
  472. margin-bottom: 7rpx;
  473. background-color: #2752eb;
  474. margin-right: 8rpx;
  475. }
  476. .titlet2{
  477. font-weight: 800;
  478. color: #2752eb;
  479. }
  480. .titlebb{
  481. color: #000000;
  482. font-weight: 800;
  483. padding-left: 40rpx;
  484. background-color: #ffffff;
  485. padding-top: 20rpx;
  486. }
  487. .flexC{
  488. display: flex;
  489. }
  490. .bt1{
  491. flex:1;
  492. margin: 30rpx;
  493. }
  494. .bt2{
  495. flex:1;
  496. margin: 30rpx;
  497. }
  498. </style>