municipal.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <template>
  2. <view>
  3. <view class="view-bg">
  4. <view>
  5. <view class="uni-list-cell">
  6. <view class="uni-list-cell-left">
  7. 工程类型
  8. </view>
  9. <view class="uni-list-cell-db">
  10. <view v-if="this.isEmpty(this.projectValue.dictValue)" style="margin-top: 10;"
  11. @click="pickerShow('gcType')">
  12. <span style="color: darkgray;">请选择工程类型</span>
  13. </view>
  14. <view v-else style="margin-top: 10;" @click="pickerShow('gcType')">
  15. <span style="color: black;">{{projectValue.dictLabel}}</span>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="uni-common-mt" style="width: 100%;">
  20. <text class="uni-title uni-common-pl">建设单位</text>
  21. <view style="width: 100%;padding-right: 20rpx;box-sizing: border-box;">
  22. <textarea class="textarea" placeholder="请输入建设单位" maxlength="100"
  23. placeholder-style="padding: 10rpx;"
  24. style="width: 100%;height: 100%;border: 1rpx solid #cccccc; border-radius: 15rpx;padding: 10rpx;line-height:normal;"
  25. auto-height v-model="buildUnit"></textarea>
  26. </view>
  27. </view>
  28. <view class="uni-common-mt" style="width: 100%;">
  29. <text class="uni-title uni-common-pl">项目负责人</text>
  30. <view style="width: 100%;padding-right: 20rpx;box-sizing: border-box;">
  31. <textarea class="textarea" placeholder="请输入项目负责人" maxlength="16"
  32. placeholder-style="padding: 10rpx;"
  33. style="width: 100%;height: 100%;border: 1rpx solid #cccccc; border-radius: 15rpx;padding: 10rpx;line-height:normal;"
  34. auto-height v-model="projectLeader"></textarea>
  35. </view>
  36. </view>
  37. <view class="uni-common-mt" style="width: 100%;">
  38. <text class="uni-title uni-common-pl">现场负责人</text>
  39. <view style="width: 100%;padding-right: 20rpx;box-sizing: border-box;">
  40. <textarea class="textarea" placeholder="请输入现场负责人" maxlength="16"
  41. placeholder-style="padding: 10rpx;"
  42. style="width: 100%;height: 100%;border: 1rpx solid #cccccc; border-radius: 15rpx;padding: 10rpx;line-height:normal;"
  43. auto-height v-model="sceneLeader"></textarea>
  44. </view>
  45. </view>
  46. <view class="uni-common-mt" style="width: 100%;">
  47. <text class="uni-title uni-common-pl">设计单位</text>
  48. <view style="width: 100%;padding-right: 20rpx;box-sizing: border-box;">
  49. <textarea class="textarea" placeholder="请输入设计单位" maxlength="100"
  50. placeholder-style="padding: 10rpx;"
  51. style="width: 100%;height: 100%;border: 1rpx solid #cccccc; border-radius: 15rpx;padding: 10rpx;line-height:normal;"
  52. auto-height v-model="designUnit"></textarea>
  53. </view>
  54. </view>
  55. <view class="uni-common-mt" style="width: 100%;">
  56. <text class="uni-title uni-common-pl">设计负责人</text>
  57. <view style="width: 100%;padding-right: 20rpx;box-sizing: border-box;">
  58. <textarea class="textarea" placeholder="请输入设计负责人" maxlength="16"
  59. placeholder-style="padding: 10rpx;"
  60. style="width: 100%;height: 100%;border: 1rpx solid #cccccc; border-radius: 15rpx;padding: 10rpx;line-height:normal;"
  61. auto-height v-model="designLeader"></textarea>
  62. </view>
  63. </view>
  64. <view class="uni-common-mt" style="width: 100%;">
  65. <text class="uni-title uni-common-pl">设计联系电话</text>
  66. <view style="width: 100%;padding-right: 20rpx;box-sizing: border-box;">
  67. <textarea class="textarea" placeholder="请输入设计联系电话" maxlength="11" type="number"
  68. placeholder-style="padding: 10rpx;"
  69. style="width: 100%;height: 100%;border: 1rpx solid #cccccc; border-radius: 15rpx;padding: 10rpx;line-height:normal;"
  70. auto-height v-model="designLeaderPhone"></textarea>
  71. </view>
  72. </view>
  73. <view class="uni-common-mt" style="width: 100%;">
  74. <text class="uni-title uni-common-pl">监理单位</text>
  75. <view style="width: 100%;padding-right: 20rpx;box-sizing: border-box;">
  76. <textarea class="textarea" placeholder="请输入监理单位" maxlength="100"
  77. placeholder-style="padding: 10rpx;"
  78. style="width: 100%;height: 100%;border: 1rpx solid #cccccc; border-radius: 15rpx;padding: 10rpx;line-height:normal;"
  79. auto-height v-model="controlUnit"></textarea>
  80. </view>
  81. </view>
  82. <view class="uni-common-mt" style="width: 100%;">
  83. <text class="uni-title uni-common-pl">监理负责人</text>
  84. <view style="width: 100%;padding-right: 20rpx;box-sizing: border-box;">
  85. <textarea class="textarea" placeholder="请输入监理负责人" maxlength="16"
  86. placeholder-style="padding: 10rpx;"
  87. style="width: 100%;height: 100%;border: 1rpx solid #cccccc; border-radius: 15rpx;padding: 10rpx;line-height:normal;"
  88. auto-height v-model="controlLeader"></textarea>
  89. </view>
  90. </view>
  91. <view class="uni-common-mt" style="width: 100%;">
  92. <text class="uni-title uni-common-pl">监理联系电话</text>
  93. <view style="width: 100%;padding-right: 20rpx;box-sizing: border-box;">
  94. <textarea class="textarea" placeholder="请输入监理联系电话" maxlength="11" type="number"
  95. placeholder-style="padding: 10rpx;"
  96. style="width: 100%;height: 100%;border: 1rpx solid #cccccc; border-radius: 15rpx;padding: 10rpx;line-height:normal;"
  97. auto-height v-model="controlLeaderPhone"></textarea>
  98. </view>
  99. </view>
  100. <view class="align-items" style="margin-top: 20px;margin-bottom: 20px;">
  101. <view class="container" style="color: gainsboro;">*请上传照片</view>
  102. <view class="" style="display: flex; flex-wrap: wrap;margin-top: 10px; margin-left: 10px;">
  103. <image src="/static/images/chooseimg.png" mode=""
  104. style="width: 100rpx; height: 100rpx; margin: 0 12rpx;; " @click="choose()"></image>
  105. <view v-for="(item,index) in imgArr" :key="index" style="position: relative;">
  106. <view
  107. v-if="item.substring(item.length - 3) == 'png' || item.substring(item.length - 3) == 'jpg' ">
  108. <image :src="item" mode="" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"
  109. @click="showPhoto(index)">
  110. </image>
  111. </view>
  112. <view v-else>
  113. <video :src="item" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"></video>
  114. </view>
  115. <view @click="remove(index)"
  116. style="position: absolute; top: 0; right: 14rpx; border-radius: 50%;">
  117. <uni-icons type="close" color="darkgray" size="18"></uni-icons>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. </view>
  123. </view>
  124. <view class="action-btn">
  125. <button @click="onsubmit" class="btn cu-btn block bg-blue lg round">提交</button>
  126. </view>
  127. <SelectPicker :list="dictOptions" @change="changeSelectDict" v-if="openDict" @close="closeDict"
  128. titleKey="dictLabel" subtitleKey="dictValue" v-model="dictLabel"></SelectPicker>
  129. </view>
  130. </template>
  131. <script>
  132. import SelectPicker from '../../components/selectPicker/select_picker.vue'
  133. import bottomSheet from '../../components/bottomSheet/bottomSheet.vue'
  134. import uniIcons from '../../uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
  135. import {
  136. getDicts
  137. } from "@/api/system/dict/data";
  138. import {
  139. getToken
  140. } from '../../utils/auth';
  141. import {
  142. getUserProfile
  143. } from "@/api/system/user"
  144. import {
  145. submitMunicipalData
  146. } from '@/api/common'
  147. export default {
  148. components: {
  149. SelectPicker,
  150. uniIcons
  151. },
  152. data() {
  153. return {
  154. headers: {
  155. Authorization: "Bearer " + getToken()
  156. },
  157. user: {
  158. nickName: "",
  159. phonenumber: "",
  160. email: "",
  161. sex: ""
  162. },
  163. projectValue: {},
  164. dictOptions: [],
  165. openDict: false,
  166. buildUnit: "",
  167. projectLeader: "",
  168. sceneLeader: "",
  169. designUnit: "",
  170. designLeader: "",
  171. designLeaderPhone: "",
  172. controlUnit: "",
  173. controlLeader: "",
  174. controlLeaderPhone: "",
  175. //图片相关
  176. imgArr: [],
  177. progress: 0, //上传图片进度百分比
  178. loading: false,
  179. }
  180. },
  181. methods: {
  182. isEmpty(str) {
  183. return (!str || 0 === str.length);
  184. },
  185. pickerShow(e) {
  186. this.type = e; //赋值类型
  187. this.openDict = true;
  188. if (e == 'gcType') {
  189. getDicts("industry_engin_type").then(response => { //工程类型 市政 工业
  190. this.dictOptions = response.data;
  191. });
  192. }
  193. },
  194. //关闭弹窗
  195. closeDict(e) {
  196. this.openDict = false
  197. },
  198. changeSelectDict(item, index) {
  199. this.openDict = false;
  200. if (this.type == 'gcType') {
  201. this.projectValue = item
  202. }
  203. },
  204. onsubmit() {
  205. let param = {
  206. file:[],// 附件
  207. pics:[], // 附件返回
  208. type:2,//市政:2,工业:1
  209. enginName:this.buildUnit,// 工程名称
  210. enginType:"",// 工程类型
  211. constructUnit:"", // 建筑单位
  212. projectHead:"", // 项目负责人
  213. sceneHead:"", // 现场负责人
  214. designUnit:"", // 设计单位
  215. designHead:"", // 设计负责人
  216. designPhone:"", // 设计联系电话
  217. supervisionUnit:"", // 监理单位
  218. supervisionHead:"",// 监理负责人
  219. supervisionPhone:"", // 监理联系电话
  220. enginClassification:"",// 工程分类
  221. zEngineeringNodeBo:{ // 工程节点
  222. type:"", // 节点类型
  223. zEngineeringInfoBo:{// 施工信息
  224. constructUser:"",// 施工人
  225. constructTime:"",// 施工时间
  226. zEngiineeringPhotoBoList:[],
  227. zEngineeringMaterialBo:[{// 图片列表
  228. materialQuality:"", // 用料对象
  229. specifications:"", // 用料规格
  230. number:"" // 用料数量
  231. }]
  232. }
  233. },
  234. enginType:"",
  235. };
  236. submitMunicipalData(param).then(res => {
  237. if (res.code == '200') {
  238. uni.showToast({
  239. title: res.msg,
  240. icon: 'none',
  241. //显示持续时间为 3秒
  242. duration: 2000
  243. });
  244. setTimeout(function() {
  245. uni.navigateBack();
  246. }, 1000)
  247. }
  248. this.$modal.closeLoading()
  249. })
  250. },
  251. showPhoto(index) {
  252. uni.previewImage({
  253. current: index,
  254. urls: this.imgArr,
  255. })
  256. },
  257. remove(index) {
  258. uni.showModal({
  259. title: '提示',
  260. content: '是否删除该图片或视频?',
  261. success: (res) => {
  262. if (res.confirm) {
  263. this.imgArr.splice(index, 1)
  264. console.log('this.imgarr', this.imgArr)
  265. if (this.imgArr.length <= 0) {
  266. this.photo = true;
  267. }
  268. }
  269. }
  270. })
  271. },
  272. choose() {
  273. let _this = this;
  274. uni.showActionSheet({
  275. title: '上传',
  276. itemList: ['图片', '视频'],
  277. success: (res) => {
  278. console.log(res)
  279. if (res.tapIndex == 0) {
  280. this.chooseimage()
  281. } else {
  282. this.choosevideo()
  283. }
  284. }
  285. })
  286. },
  287. chooseimage() {
  288. let _this = this;
  289. console.log('图片', _this.headers)
  290. uni.chooseImage({
  291. sizeType: ['album', 'camera'],
  292. success(resp) {
  293. resp.tempFiles.forEach((item, index) => {
  294. const task = uni.uploadFile({
  295. url: _this.$HTTP + `/obs`,
  296. filePath: item.path,
  297. name: 'file',
  298. formData: {},
  299. header: _this.headers,
  300. success: res => {
  301. // 判断是否json字符串,将其转为json格式
  302. console.log("结果", res)
  303. // let data = _this.$u.test.jsonString(res
  304. // .data) ? JSON.parse(res.data) : res.data;
  305. let data = JSON.parse(res.data);
  306. if (![200].includes(data.code)) {
  307. // this.uploadError(index, data);
  308. _this.$modal.msg(data.msg)
  309. } else {
  310. if (_this.progress === 100) {
  311. console.log('_this.progress', _this.progress)
  312. //console.log('data----', data)data
  313. console.log('res--', res)
  314. _this.imgArr.push(data.data.url)
  315. console.log('imgArr', _this.imgArr)
  316. _this.$modal.msg('上传成功!')
  317. _this.photo = false;
  318. }
  319. }
  320. },
  321. fail: e => {
  322. console.log(e)
  323. _this.$modal.msg('上传失败!')
  324. //_this.uploadError(index, e);
  325. },
  326. complete: res => {
  327. uni.hideLoading();
  328. _this.uploading = false;
  329. }
  330. });
  331. task.onProgressUpdate(res => {
  332. _this.progress = res.progress;
  333. console.log('onProgressUpdate', res)
  334. console.log('task.onProgressUpdate', _this.progress)
  335. uni.showLoading({
  336. title: '上传中'
  337. })
  338. if (_this.progress != 100) {
  339. _this.loading = false
  340. console.log('_this.loading false', _this.loading)
  341. } else {
  342. _this.loading = true
  343. console.log('_this.loading true', _this.loading)
  344. }
  345. });
  346. })
  347. },
  348. })
  349. },
  350. choosevideo() {
  351. let _this = this;
  352. console.log('视频')
  353. uni.chooseVideo({
  354. sourceType: ['album', 'camera'],
  355. maxDuration: 30,
  356. success(resp) {
  357. const task = uni.uploadFile({
  358. url: _this.$HTTP + `/obs`,
  359. filePath: resp.tempFilePath,
  360. name: 'file',
  361. formData: {},
  362. header: _this.headers,
  363. success: res => {
  364. // 判断是否json字符串,将其转为json格式
  365. let data = JSON.parse(res.data);
  366. if (![200].includes(res.statusCode)) {
  367. this.uploadError(index, data);
  368. } else {
  369. //上传成功
  370. if (_this.progress === 100) {
  371. console.log('_this.progress', _this.progress)
  372. _this.imgArr.push(data.data.url)
  373. console.log('imgArr', _this.imgArr)
  374. _this.$modal.msg('上传成功!')
  375. _this.photo = false;
  376. }
  377. }
  378. },
  379. fail: e => {
  380. _this.$modal.msg('上传失败!')
  381. this.uploadError(index, e);
  382. },
  383. complete: res => {
  384. uni.hideLoading();
  385. _this.uploading = false;
  386. }
  387. });
  388. task.onProgressUpdate(res => {
  389. _this.progress = res.progress;
  390. console.log('onProgressUpdate', res)
  391. uni.showLoading({
  392. title: '上传中'
  393. })
  394. if (_this.progress != 100) {
  395. _this.loading = false
  396. console.log('_this.loading false', _this.loading)
  397. } else {
  398. _this.loading = true
  399. console.log('_this.loading true', _this.loading)
  400. }
  401. });
  402. },
  403. })
  404. },
  405. }
  406. }
  407. </script>
  408. <style>
  409. .container {
  410. display: flex;
  411. margin-left: 10px;
  412. margin-top: 10px;
  413. margin-right: 10px;
  414. align-items: flex-start;
  415. justify-content: space-between;
  416. }
  417. .text {
  418. font-size: 16px;
  419. color: #333;
  420. }
  421. .background {
  422. border: 15px solid hsla(0, 0%, 100%, .5);
  423. background: white;
  424. background-clip: padding-box;
  425. /*从padding开始往外面裁剪背景*/
  426. }
  427. .btn {
  428. margin-top: 40px;
  429. margin-right: 20px;
  430. margin-bottom: 120px;
  431. margin-left: 20px;
  432. height: 45px;
  433. }
  434. .number {
  435. display: flex;
  436. /* 水平居中显示子元素 */
  437. align-items: flex-start;
  438. /* 垂直居中显示子元素 */
  439. justify-content: space-between;
  440. /* 左右间距等于间距大小 */
  441. padding: 10px;
  442. /* 设置padding以提高视觉效果 */
  443. }
  444. .textarea {
  445. margin-top: 10upx;
  446. width: 100%;
  447. border: 1rpx solid red;
  448. min-height: 100upx;
  449. line-height: 20px;
  450. }
  451. .uni-list-cell-db,
  452. .uni-list-cell {
  453. position: relative;
  454. display: flex;
  455. flex-direction: row;
  456. justify-content: space-between;
  457. align-items: center;
  458. }
  459. .uni-list-cell-left {
  460. white-space: nowrap;
  461. font-size: 28rpx;
  462. }
  463. .view-bg {
  464. margin-left: 8px;
  465. margin-right: 8px;
  466. margin-top: 8px;
  467. padding: 10px;
  468. background-color: #fff;
  469. border-radius: 5px;
  470. }
  471. </style>