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.bz5}}
  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. },
  166. t1: '可供产品',
  167. t1s: '请填写可供产品',
  168. t2: '可供数量',
  169. t2s: '请填写可供数量',
  170. t3: '详细描述',
  171. t3s: '请填写详细描述',
  172. autoUpload: false,
  173. picLists: [],
  174. picUrl: [],
  175. imageStyles: {
  176. width: 90,
  177. height: 90
  178. },
  179. parkList: [ "用工人才", "资金需求", "土地厂房", "订单及配套", "政策兑现", "创新及品牌", "审批手续", "水电气供应", "安全环保消防", "其他(需详细说明)"],
  180. questionList:[{qname:"",qtype:"",qTypeindex:"",gaps:"",des:"",t1:"",t1s:"",checkUserList:[]}],
  181. index:0,
  182. ischeck: false,
  183. canedit:true,
  184. pickerData: [],
  185. pickerDataOld: []
  186. }
  187. },
  188. created() {
  189. },
  190. mounted() {
  191. },
  192. async onLoad(query) {
  193. if(query.ischeck!=undefined&&query.ischeck=='1'){
  194. //查看
  195. this.ischeck=true;
  196. let data2 = await loginService.getdzfQuestionqueryById({id:query.id})
  197. this.inputForm.id = data2.data.id;
  198. this.inputForm.name = data2.data.qyName;
  199. this.inputForm.qySd = data2.data.qySd;
  200. this.inputForm.lxr = data2.data.qyFzr;
  201. this.inputForm.phone = data2.data.phone;
  202. this.inputForm.bz5 = data2.data.officer;
  203. for (let i = 0; i < data2.data.dzfQuestionDetilDTOList.length; i++) {
  204. data2.data.dzfQuestionDetilDTOList[i].checkUserList=[];
  205. if (data2.data.dzfQuestionDetilDTOList[i].des7 != ''&&data2.data.dzfQuestionDetilDTOList[i].des7 != undefined) {
  206. data2.data.dzfQuestionDetilDTOList[i].checkUserList=data2.data.dzfQuestionDetilDTOList[i].des7.split(",");
  207. }
  208. }
  209. this.questionList=data2.data.dzfQuestionDetilDTOList;
  210. //不是暂存时不可以修改
  211. if(data2.data.states!='0'){
  212. this.canedit=false;
  213. }
  214. }else{
  215. //新增
  216. let data2 = await loginService.queryByUserName()
  217. this.inputForm = this.recover(this.inputForm, data2.data)
  218. this.inputForm.qySd = data2.data.des1;
  219. this.inputForm.id="";
  220. }
  221. },
  222. methods: {
  223. //交办单位
  224. selectChange2() {
  225. // 此处为点击的事件
  226. this.pickerData=this.pickerDataOld;
  227. },
  228. searchEvent(val) {
  229. this.pickerData=this.filteredItems(val);
  230. },
  231. filteredItems(searchQuery) {
  232. const query = searchQuery.trim();
  233. if (!query) return this.pickerDataOld;
  234. return this.pickerDataOld.filter(item => {
  235. return item.label.toString().includes(query);
  236. });
  237. },
  238. //交办单位结束
  239. addp(){
  240. this.questionList.push({qname:"",qtype:"",qTypeindex:"",gaps:"",des:"",t1:"",t1s:"",checkUserList:[]})
  241. },
  242. del(index2){
  243. this.questionList.splice(index2, 1);
  244. },
  245. bindPickerChange: function(e,index2) {
  246. if(e.detail.value==0){
  247. this.questionList[index2].t1='缺口数';
  248. this.questionList[index2].t1s= '请填写缺口数';
  249. this.questionList[index2].t1d= '人';
  250. }else if(e.detail.value==1){
  251. this.questionList[index2].t1='缺口数';
  252. this.questionList[index2].t1s= '请填写缺口数';
  253. this.questionList[index2].t1d= '万元';
  254. }else if(e.detail.value==2){
  255. this.questionList[index2].t1='缺口数';
  256. this.questionList[index2].t1s= '请填写缺口数';
  257. this.questionList[index2].t1d= '';
  258. }else{
  259. this.questionList[index2].t1='';
  260. this.questionList[index2].t1s= '';
  261. this.questionList[index2].t1d= '';
  262. }
  263. this.questionList[index2].qTypeindex = e.detail.value;
  264. this.questionList[index2].qtype=this.parkList[e.detail.value]
  265. },
  266. // 获取上传进度
  267. progress(e) {
  268. console.log('上传进度:', e)
  269. },
  270. // 上传成功
  271. success(e) {
  272. console.log('上传成功')
  273. },
  274. // 上传失败
  275. fail(e) {
  276. console.log('上传失败:', e)
  277. },
  278. deleteFile(e) {
  279. this.picUrl.splice(e.index, 1)
  280. },
  281. // 获取上传状态
  282. select(e) {
  283. console.log('选择文件:', e)
  284. var _this = this
  285. var i = 0
  286. upload()
  287. function upload() {
  288. if (i >= e.tempFiles.length) {
  289. return;
  290. }
  291. var item = e.tempFiles[i]
  292. uni.showLoading({
  293. title: "上传中",
  294. mask: true
  295. });
  296. uni.uploadFile({
  297. url: '/yd_qycpfb/file/upload?uploadPath=userdir', // 仅为示例,非真实的接口地址
  298. filePath: item.url,
  299. name: 'file',
  300. formData: {
  301. 'fileName': item.name
  302. },
  303. header: {
  304. 'token': _this.$auth.getUserToken()
  305. },
  306. success: (res) => {
  307. var data = res.data
  308. if (typeof data['error'] != "undefined") {
  309. uni.showToast({
  310. icon: 'none',
  311. title: '上传失败,请联系开发!'
  312. });
  313. _this.$refs.picFile.clearFiles(_this.picLists.length)
  314. } else {
  315. _this.picUrl.push({
  316. url: data,
  317. uuid: item.uuid
  318. })
  319. i++;
  320. upload()
  321. }
  322. },
  323. fail: () => {
  324. uni.hideLoading();
  325. uni.showToast({
  326. icon: 'none',
  327. title: '上传失败,请联系开发!'
  328. });
  329. _this.$refs.picFile.clearFiles(_this.picLists.length)
  330. },
  331. complete: function() {
  332. uni.hideLoading();
  333. }
  334. });
  335. }
  336. },
  337. save(){
  338. this.inputForm.des10="";
  339. this.getJBBM();
  340. this.inputForm.dzfQuestionDetilDTOList=this.questionList;
  341. this.checkinput();
  342. },
  343. formSubmit: function(e) {
  344. this.inputForm.des10="submit";
  345. this.getJBBM();
  346. this.inputForm.dzfQuestionDetilDTOList=this.questionList;
  347. this.checkinput();
  348. },
  349. getJBBM(){
  350. //将交办单位的名称带出
  351. for (let i = 0; i < this.questionList.length; i++) {
  352. if (this.questionList[i].checkUserList != []) {
  353. this.questionList[i].checkUserListName=this.questionList[i].checkUserList.map((value) => {
  354. const item = this.pickerData.find((option) => option.value === value);
  355. return item ? item.label : value; // 如果找不到,返回 value
  356. })
  357. .join(",");
  358. }
  359. this.questionList[i].checkUserList=this.questionList[i].checkUserList.join(",");
  360. }
  361. },
  362. checkinput(){
  363. if(this.hasDuplicateQName(this.questionList)){
  364. uni.showToast({
  365. icon: 'none',
  366. title: '问题名称不能重复!'
  367. });
  368. }else{
  369. uni.showLoading()
  370. loginService.saveQuestion(this.inputForm).then(({
  371. data
  372. }) => {
  373. uni.hideLoading();
  374. uni.showToast({
  375. title: "问题诉求提交成功!",
  376. icon: "success"
  377. });
  378. uni.navigateTo({
  379. url: '/pages/question/questionList'
  380. })
  381. }).catch((e) => {
  382. uni.hideLoading();
  383. })
  384. }
  385. },
  386. hasDuplicateQName(array) {
  387. const seen = new Set();
  388. for (const item of array) {
  389. if (seen.has(item.qname)) {
  390. return true; // 找到重复的 qName
  391. }
  392. seen.add(item.qname);
  393. }
  394. return false; // 没有重复的 qName
  395. }
  396. }
  397. }
  398. </script>
  399. <style>
  400. /* .file-title) {
  401. font-size: 17px !important;
  402. } */
  403. input,textarea{
  404. color: #8799a3;
  405. }
  406. .input1{
  407. background-color: #ffffff;
  408. padding: 1upx 40upx;
  409. display: flex;
  410. align-items: center;
  411. padding-top: 20upx;
  412. border-bottom: 1px solid #eee;
  413. }
  414. .input1 .title {
  415. text-align: justify;
  416. padding-right: 30upx;
  417. font-size: 30upx;
  418. position: relative;
  419. height: 60upx;
  420. line-height: 60upx;
  421. border: ;
  422. }
  423. .title2{
  424. width: 75%;
  425. text-align: left;
  426. }
  427. .input2 {
  428. flex: 1;
  429. font-size: 30upx;
  430. color: #555;
  431. padding-right: 20upx;
  432. width: 500rpx;
  433. }
  434. .uni-input{
  435. }
  436. .textbg{
  437. display: flex;
  438. background-color: white;
  439. padding-top: 29rpx;
  440. }
  441. .text12{
  442. width: 200rpx;
  443. margin-left: 30rpx;
  444. color: #000000;
  445. font-size: 29rpx;
  446. }
  447. .text2{
  448. flex: 1;
  449. color: #000000;
  450. font-size: 30rpx;
  451. padding-bottom: 2rpx;
  452. }
  453. .text22{
  454. flex: 1;
  455. color: #666666;
  456. font-size: 29rpx;
  457. padding-bottom: 2rpx;
  458. align-self: flex-end;
  459. }
  460. .titlebg2{
  461. display: flex;
  462. background-color: white;
  463. padding-left: 22rpx;
  464. padding-top: 35rpx;
  465. padding-bottom: 25rpx;
  466. margin-bottom: 2rpx;
  467. }
  468. .titlet1{
  469. width: 7rpx;
  470. margin-top: 7rpx;
  471. margin-bottom: 7rpx;
  472. background-color: #2752eb;
  473. margin-right: 8rpx;
  474. }
  475. .titlet2{
  476. font-weight: 800;
  477. color: #2752eb;
  478. }
  479. .titlebb{
  480. color: #000000;
  481. font-weight: 800;
  482. padding-left: 40rpx;
  483. background-color: #ffffff;
  484. padding-top: 20rpx;
  485. }
  486. .flexC{
  487. display: flex;
  488. }
  489. .bt1{
  490. flex:1;
  491. margin: 30rpx;
  492. }
  493. .bt2{
  494. flex:1;
  495. margin: 30rpx;
  496. }
  497. </style>