questionAdd.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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.qy_sd}}
  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" style="border-bottom: 3px solid #eee;">
  91. <view class="title">
  92. 问题描述
  93. </view>
  94. <textarea v-model="item.des" placeholder="请填写问题描述" :disabled="!canedit" ></textarea>
  95. </view>
  96. </view>
  97. <view style="width: 400rpx;margin-left: 20rpx;">
  98. <button v-if="canedit" @click="addp" style="height: 30px;" class="cu-btn block bg-blue margin-tb-sm lg">+增加问题</button>
  99. </view>
  100. <view style="height: 40rpx;"></view>
  101. <view class="flexC" v-if="canedit">
  102. <button @click="save" class="bt1 block margin-tb-sm lg">暂存</button>
  103. <button form-type="submit" class="bt1 cu-btn block bg-blue margin-tb-sm lg">提交</button>
  104. </view>
  105. <view style="height: 40rpx;"></view>
  106. </form>
  107. </view>
  108. </template>
  109. <script>
  110. var graceChecker = require("@/common/graceChecker.js");
  111. import revenueListService from '@/api/revenue/revenueListService'
  112. import loginService from '@/api/auth/loginService.js'
  113. export default {
  114. onShow() {
  115. this.$auth.checkLogin()
  116. },
  117. data() {
  118. return {
  119. title: '问题诉求情况',
  120. inputForm: {
  121. id:'',
  122. name: '',
  123. qy_sd: '',
  124. lxr: '',
  125. phone: '',
  126. bz5: '',
  127. },
  128. t1: '可供产品',
  129. t1s: '请填写可供产品',
  130. t2: '可供数量',
  131. t2s: '请填写可供数量',
  132. t3: '详细描述',
  133. t3s: '请填写详细描述',
  134. autoUpload: false,
  135. picLists: [],
  136. picUrl: [],
  137. imageStyles: {
  138. width: 90,
  139. height: 90
  140. },
  141. parkList: [ "用工人才", "资金需求", "土地厂房", "订单及配套", "政策兑现", "创新及品牌", "审批手续", "水电气供应", "安全环保消防", "其他(需详细说明)"],
  142. questionList:[{qname:"",qtype:"",qTypeindex:"",gaps:"",des:"",t1:"",t1s:""}],
  143. index:0,
  144. ischeck: false,
  145. canedit:true,
  146. }
  147. },
  148. created() {
  149. },
  150. mounted() {
  151. },
  152. async onLoad(query) {
  153. if(query.ischeck!=undefined&&query.ischeck=='1'){
  154. //查看
  155. this.ischeck=true;
  156. let data2 = await loginService.getdzfQuestionqueryById({id:query.id})
  157. this.inputForm.id = data2.data.id;
  158. this.inputForm.name = data2.data.qyName;
  159. this.inputForm.qy_sd = data2.data.des1;
  160. this.inputForm.lxr = data2.data.qyFzr;
  161. this.inputForm.phone = data2.data.phone;
  162. this.inputForm.bz5 = data2.data.officer;
  163. this.questionList=data2.data.dzfQuestionDetilDTOList;
  164. //不是暂存时不可以修改
  165. if(data2.data.states!='0'){
  166. this.canedit=false;
  167. }
  168. }else{
  169. //新增
  170. let data2 = await loginService.queryByUserName()
  171. this.inputForm = this.recover(this.inputForm, data2.data)
  172. this.inputForm.id="";
  173. }
  174. },
  175. methods: {
  176. addp(){
  177. this.questionList.push({qname:"",qtype:"",qTypeindex:"",gaps:"",des:"",t1:"",t1s:""})
  178. },
  179. del(index2){
  180. this.questionList.splice(index2, 1);
  181. },
  182. bindPickerChange: function(e,index2) {
  183. if(e.detail.value==0){
  184. this.questionList[index2].t1='缺口数';
  185. this.questionList[index2].t1s= '请填写缺口数';
  186. this.questionList[index2].t1d= '人';
  187. }else if(e.detail.value==1){
  188. this.questionList[index2].t1='缺口数';
  189. this.questionList[index2].t1s= '请填写缺口数';
  190. this.questionList[index2].t1d= '万元';
  191. }else if(e.detail.value==2){
  192. this.questionList[index2].t1='缺口数';
  193. this.questionList[index2].t1s= '请填写缺口数';
  194. this.questionList[index2].t1d= '';
  195. }else{
  196. this.questionList[index2].t1='';
  197. this.questionList[index2].t1s= '';
  198. this.questionList[index2].t1d= '';
  199. }
  200. this.questionList[index2].qTypeindex = e.detail.value;
  201. this.questionList[index2].qtype=this.parkList[e.detail.value]
  202. },
  203. // 获取上传进度
  204. progress(e) {
  205. console.log('上传进度:', e)
  206. },
  207. // 上传成功
  208. success(e) {
  209. console.log('上传成功')
  210. },
  211. // 上传失败
  212. fail(e) {
  213. console.log('上传失败:', e)
  214. },
  215. deleteFile(e) {
  216. this.picUrl.splice(e.index, 1)
  217. },
  218. // 获取上传状态
  219. select(e) {
  220. console.log('选择文件:', e)
  221. var _this = this
  222. var i = 0
  223. upload()
  224. function upload() {
  225. if (i >= e.tempFiles.length) {
  226. return;
  227. }
  228. var item = e.tempFiles[i]
  229. uni.showLoading({
  230. title: "上传中",
  231. mask: true
  232. });
  233. uni.uploadFile({
  234. url: '/yd_qycpfb/file/upload?uploadPath=userdir', // 仅为示例,非真实的接口地址
  235. filePath: item.url,
  236. name: 'file',
  237. formData: {
  238. 'fileName': item.name
  239. },
  240. header: {
  241. 'token': _this.$auth.getUserToken()
  242. },
  243. success: (res) => {
  244. var data = res.data
  245. if (typeof data['error'] != "undefined") {
  246. uni.showToast({
  247. icon: 'none',
  248. title: '上传失败,请联系开发!'
  249. });
  250. _this.$refs.picFile.clearFiles(_this.picLists.length)
  251. } else {
  252. _this.picUrl.push({
  253. url: data,
  254. uuid: item.uuid
  255. })
  256. i++;
  257. upload()
  258. }
  259. },
  260. fail: () => {
  261. uni.hideLoading();
  262. uni.showToast({
  263. icon: 'none',
  264. title: '上传失败,请联系开发!'
  265. });
  266. _this.$refs.picFile.clearFiles(_this.picLists.length)
  267. },
  268. complete: function() {
  269. uni.hideLoading();
  270. }
  271. });
  272. }
  273. },
  274. save(){
  275. this.inputForm.des10="";
  276. this.inputForm.dzfQuestionDetilDTOList=this.questionList;
  277. this.checkinput();
  278. },
  279. formSubmit: function(e) {
  280. this.inputForm.des10="submit";
  281. this.inputForm.dzfQuestionDetilDTOList=this.questionList;
  282. this.checkinput();
  283. },
  284. checkinput(){
  285. if(this.hasDuplicateQName(this.questionList)){
  286. uni.showToast({
  287. icon: 'none',
  288. title: '问题名称不能重复!'
  289. });
  290. }else{
  291. uni.showLoading()
  292. loginService.saveQuestion(this.inputForm).then(({
  293. data
  294. }) => {
  295. uni.hideLoading();
  296. uni.showToast({
  297. title: "问题诉求提交成功!",
  298. icon: "success"
  299. });
  300. uni.navigateTo({
  301. url: '/pages/question/questionList'
  302. })
  303. }).catch((e) => {
  304. uni.hideLoading();
  305. })
  306. }
  307. },
  308. hasDuplicateQName(array) {
  309. const seen = new Set();
  310. for (const item of array) {
  311. if (seen.has(item.qname)) {
  312. return true; // 找到重复的 qName
  313. }
  314. seen.add(item.qname);
  315. }
  316. return false; // 没有重复的 qName
  317. }
  318. }
  319. }
  320. </script>
  321. <style>
  322. /* .file-title) {
  323. font-size: 17px !important;
  324. } */
  325. input,textarea{
  326. color: #8799a3;
  327. }
  328. .input1{
  329. background-color: #ffffff;
  330. padding: 1upx 40upx;
  331. display: flex;
  332. align-items: center;
  333. padding-top: 20upx;
  334. border-bottom: 1px solid #eee;
  335. }
  336. .input1 .title {
  337. text-align: justify;
  338. padding-right: 30upx;
  339. font-size: 30upx;
  340. position: relative;
  341. height: 60upx;
  342. line-height: 60upx;
  343. border: ;
  344. }
  345. .title2{
  346. width: 75%;
  347. text-align: left;
  348. }
  349. .input2 {
  350. flex: 1;
  351. font-size: 30upx;
  352. color: #555;
  353. padding-right: 20upx;
  354. width: 500rpx;
  355. }
  356. .uni-input{
  357. }
  358. .textbg{
  359. display: flex;
  360. background-color: white;
  361. padding-top: 29rpx;
  362. }
  363. .text12{
  364. width: 200rpx;
  365. margin-left: 30rpx;
  366. color: #000000;
  367. font-size: 29rpx;
  368. }
  369. .text2{
  370. flex: 1;
  371. color: #000000;
  372. font-size: 30rpx;
  373. padding-bottom: 2rpx;
  374. }
  375. .text22{
  376. flex: 1;
  377. color: #666666;
  378. font-size: 29rpx;
  379. padding-bottom: 2rpx;
  380. align-self: flex-end;
  381. }
  382. .titlebg2{
  383. display: flex;
  384. background-color: white;
  385. padding-left: 22rpx;
  386. padding-top: 35rpx;
  387. padding-bottom: 25rpx;
  388. margin-bottom: 2rpx;
  389. }
  390. .titlet1{
  391. width: 7rpx;
  392. margin-top: 7rpx;
  393. margin-bottom: 7rpx;
  394. background-color: #2752eb;
  395. margin-right: 8rpx;
  396. }
  397. .titlet2{
  398. font-weight: 800;
  399. color: #2752eb;
  400. }
  401. .titlebb{
  402. color: #000000;
  403. font-weight: 800;
  404. padding-left: 40rpx;
  405. background-color: #ffffff;
  406. padding-top: 20rpx;
  407. }
  408. .flexC{
  409. display: flex;
  410. }
  411. .bt1{
  412. flex:1;
  413. margin: 30rpx;
  414. }
  415. .bt2{
  416. flex:1;
  417. margin: 30rpx;
  418. }
  419. </style>