enginproject.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180
  1. <template>
  2. <view>
  3. <view class="background">
  4. <view class="uni-list">
  5. <view class="container">
  6. <view>
  7. 工程类型
  8. </view>
  9. <view v-if="this.isEmpty(this.projectType.dictValue)" style="margin-top: 10;"
  10. @click="pickerShow('gclx',0)">
  11. <span style="color: darkgray;">请选择工程类型</span>
  12. </view>
  13. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('gclx',0)">
  14. <span style="color: black;">{{projectType.dictLabel}}</span>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="uni-list">
  19. <view class="container">
  20. <view>
  21. 工程名称
  22. </view>
  23. <view v-if="this.isEmpty(this.projectName.id)" style="margin-top: 10;"
  24. @click="pickerShow('gcmc',0)">
  25. <span style="color: darkgray;">请选择工程名称</span>
  26. </view>
  27. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('gcmc',0)">
  28. <span style="color: black;">{{projectName.name}}</span>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="uni-list">
  33. <view class="container">
  34. <text>建设单位</text>
  35. <input class="uni-input" type="text" v-model="jsdwValue" maxlength="100" disabled="true"
  36. style="margin-left: 10px;text-align: right;"></input>
  37. </view>
  38. </view>
  39. <view class="uni-list">
  40. <view class="container">
  41. <text>项目负责人</text>
  42. <input class="uni-input" type="text" v-model="xmfzrValue" maxlength="16" disabled="true"
  43. style="margin-left: 10px;text-align: right;"></input>
  44. </view>
  45. </view>
  46. <view class="uni-list">
  47. <view class="container">
  48. <text>现场负责人</text>
  49. <input class="uni-input" type="text" v-model="xcfzrValue" maxlength="16" disabled="true"
  50. style="margin-left: 10px;text-align: right;"></input>
  51. </view>
  52. </view>
  53. <view class="uni-list">
  54. <view class="container">
  55. <text>设计单位</text>
  56. <input class="uni-input" type="text" v-model="sjdwValue" maxlength="100" disabled="true"
  57. style="margin-left: 10px;text-align: right;"></input>
  58. </view>
  59. </view>
  60. <view class="uni-list">
  61. <view class="container">
  62. <text>设计负责人</text>
  63. <input class="uni-input" type="text" v-model="sjfzrValue" maxlength="16" disabled="true"
  64. style="margin-left: 10px;text-align: right;"></input>
  65. </view>
  66. </view>
  67. <view class="uni-list">
  68. <view class="container">
  69. <text>设计联系电话</text>
  70. <input class="uni-input" type="number" v-model="sjPhoneValue" disabled="true" maxlength="11"
  71. style="margin-left: 10px;text-align: right;"></input>
  72. </view>
  73. </view>
  74. <view class="uni-list">
  75. <view class="container">
  76. <text>监理单位</text>
  77. <input class="uni-input" type="text" v-model="jldwValue" maxlength="100" disabled="true"
  78. style="margin-left: 10px;text-align: right;"></input>
  79. </view>
  80. </view>
  81. <view class="uni-list">
  82. <view class="container">
  83. <text>监理负责人</text>
  84. <input class="uni-input" type="text" v-model="jlfzrValue" maxlength="16" disabled="true"
  85. style="margin-left: 10px;text-align: right;"></input>
  86. </view>
  87. </view>
  88. <view class="uni-list">
  89. <view class="container">
  90. <text>监理联系电话</text>
  91. <input class="uni-input" type="number" v-model="jlPhoneValue" disabled="true" maxlength="11"
  92. style="margin-left: 10px;text-align: right;"></input>
  93. </view>
  94. </view>
  95. <view class="uni-list">
  96. <view class="align-items" style="margin-bottom: 20px;">
  97. <!-- <view class="container" style="color: gainsboro;">*请上传文件</view> -->
  98. <view class="" style="display: flex; flex-wrap: wrap;margin-top: 10px; margin-left: 10px;">
  99. <!-- <image src="/static/images/chooseimg.png" mode=""
  100. style="width: 100rpx; height: 100rpx; margin: 0 12rpx;; " @click="chooseFile()"></image> -->
  101. <view v-for="(item,index) in fileArr" :key="index" style="position: relative;">
  102. <view style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"
  103. @click="chooseModel(item.picUrl,item.fileName)">
  104. {{item.fileName}}
  105. <!-- <image :src="item" mode="" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;">
  106. </image> -->
  107. </view>
  108. <!-- <view @click="removeFile(index)"
  109. style="position: absolute; top: 0; right: 14rpx; border-radius: 50%;">
  110. <uni-icons type="close" color="darkgray" size="18"></uni-icons>
  111. </view> -->
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. <SelectPicker :list="selectList" @change="changeSelect" v-if="open" @close="close" titleKey="name"
  117. subtitleKey="id" v-model="name"></SelectPicker>
  118. <SelectPicker :list="dictOptions" @change="changeSelectDict" v-if="openDict" @close="closeDict"
  119. titleKey="dictLabel" subtitleKey="dictValue" v-model="dictLabel"></SelectPicker>
  120. </view>
  121. <view class="background">
  122. <view>
  123. <view class="uni-list">
  124. <view style="font-size: 16px;margin-left: 10px;margin-top: 10px;">
  125. {{objValue.value}}
  126. <span
  127. style="color: blue;font-size: 14px; display: flex;justify-content:flex-end; margin-right: 15px;"
  128. @click="history">历史</span>
  129. </view>
  130. <view class="container">
  131. <view>
  132. 施工时间
  133. </view>
  134. <view style="margin-top: 10;" @click="openDatetimePicker()">
  135. <span style="color: black;">{{time}}</span>
  136. </view>
  137. </view>
  138. <view v-for="(a,index) in czggslList" :key="index">
  139. <view class="container">
  140. <view>
  141. 材质
  142. </view>
  143. <view class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('cz',index)">
  144. <span style="color: black;">{{a.cz.id==''?'请选择材质':a.cz.name}}</span>
  145. </view>
  146. </view>
  147. <view class="container">
  148. <view>
  149. 规格
  150. </view>
  151. <view class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('gg',index)">
  152. <span style="color: black;">{{a.gg.id==''?'请选择规格':a.gg.name}}</span>
  153. </view>
  154. </view>
  155. <view class="container">
  156. <text>数量</text>
  157. <input class="uni-input" type="number" v-model="a.sl" placeholder="请填写数量" maxlength="11"
  158. style="margin-left: 10px;text-align: right;"></input>
  159. </view>
  160. <button v-if="index!=0" @click="this.czggslList.splice(index,1)">删除</button>
  161. </view>
  162. <button
  163. @click="this.czggslList.push({cz:{id: '',name: ''},gg:{id: '',name: ''},sl:''})">添加</button>
  164. </view>
  165. <view class="align-items" style="margin-top: 20px;margin-bottom: 20px;">
  166. <view class="container" style="color: gainsboro;">*请上传照片</view>
  167. <view class="" style="display: flex; flex-wrap: wrap;margin-top: 10px; margin-left: 10px;">
  168. <image src="/static/images/chooseimg.png" mode=""
  169. style="width: 100rpx; height: 100rpx; margin: 0 12rpx;; " @click="choose()"></image>
  170. <view v-for="(item,index) in imgArr" :key="index" style="position: relative;">
  171. <view
  172. v-if="item.substring(item.length - 3) == 'png' || item.substring(item.length - 3) == 'jpg' ">
  173. <image :src="item" mode="" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"
  174. @click="showPhoto(index)">
  175. </image>
  176. </view>
  177. <view v-else>
  178. <video :src="item" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"></video>
  179. </view>
  180. <view @click="remove(index)"
  181. style="position: absolute; top: 0; right: 14rpx; border-radius: 50%;">
  182. <uni-icons type="close" color="darkgray" size="18"></uni-icons>
  183. </view>
  184. </view>
  185. </view>
  186. </view>
  187. </view>
  188. </view>
  189. <view class="action-btn">
  190. <button @click="submit" class="btn cu-btn block bg-blue lg round">确认上传</button>
  191. </view>
  192. <bottom-sheet ref="refShare" :data="historyList" :TitleType="objValue.value"></bottom-sheet>
  193. <yt-dateTimePicker ref="myPicker" @submit="handleSubmit" :start-year="2024" :end-year="2099"
  194. :time-hide="[true, true, true, true, true, true]" :time-label="['年', '月', '日', '时', '分', '秒']" />
  195. <!-- 下载提示页面 -->
  196. <mypopup :show="show_loding" :popupText="popupText" :titleText="titleText" :cancelText="cancelText"
  197. :confirmText="confirmText" @close="cancel_loding" @confirm="confirm_loding">
  198. </mypopup>
  199. </view>
  200. </template>
  201. <script>
  202. import SelectPicker from '../../components/selectPicker/select_picker.vue'
  203. import bottomSheet from '../../components/bottomSheet/bottomSheetMore.vue'
  204. import mypopup from '../../components/mypopup/mypopup.vue'
  205. import uniIcons from '../../uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
  206. import {
  207. getDicts
  208. } from "@/api/system/dict/data";
  209. import {
  210. getEnginMaterialQualityList,
  211. getEnginSpecificationsList,
  212. getRoomProjectList,
  213. getRoomProjectId,
  214. Submitengineering,
  215. getengineeringNameList,
  216. getEngineeringDetails,
  217. getEngineeringHistoryList,
  218. } from '@/api/common'
  219. import {
  220. getToken
  221. } from '../../utils/auth';
  222. import {
  223. getUserProfile
  224. } from "@/api/system/user"
  225. export default {
  226. components: {
  227. SelectPicker,
  228. uniIcons,
  229. bottomSheet,
  230. mypopup
  231. },
  232. data() {
  233. return {
  234. historyList: {}, //历史数据
  235. show_loding: false,
  236. popupText: '', //对话框内容
  237. titleText: '',
  238. cancelText: '',
  239. confirmText: '',
  240. zEngineeringMaterialBo: [], //给后台传的值 用料列表
  241. czggslList: [{
  242. cz: {
  243. id: '',
  244. name: ''
  245. },
  246. gg: {
  247. id: '',
  248. name: ''
  249. },
  250. sl: ''
  251. }, ],
  252. conLists: [],
  253. headers: {
  254. Authorization: "Bearer " + getToken()
  255. },
  256. time: '', //施工时间
  257. user: {
  258. nickName: "",
  259. phonenumber: "",
  260. email: "",
  261. sex: ""
  262. },
  263. loading: false,
  264. loadingFile: false,
  265. projectType: {}, //工程类型
  266. open: false,
  267. objValue: '', //上一页面传过来的值 新增接口用
  268. openDict: false,
  269. specificationValue: {}, //规格
  270. projectContent: '', //施工内容
  271. materialValue: {}, //材质
  272. selectList: [],
  273. dictOptions: [],
  274. imgArr: [],
  275. fileArr: [],
  276. fileNameArr: [],
  277. type: '',
  278. jlPhoneValue: '', //监理电话
  279. jlfzrValue: '', //监理负责人
  280. jldwValue: '', //监理单位
  281. sjPhoneValue: '', //设计电话
  282. sjfzrValue: '', //设计负责人
  283. sjdwValue: '', //设计单位
  284. xcfzrValue: '', //现场负责人
  285. xmfzrValue: '', //项目负责人
  286. jsdwValue: '', //建设单位
  287. projectName: '', //工程名称
  288. SelectIndex: '', //选择的索引值
  289. fileUrl: '', //点击的文件地址
  290. fileName: '', //点击的文件名称
  291. enginList: {}, //工程信息
  292. enginId: '', //工程id
  293. createTime: '',
  294. infonId: '', //info id
  295. }
  296. },
  297. created() {
  298. this.getUser();
  299. this.time = this.traversalTime(new Date().getTime()) //在data里定义变量-nowTime
  300. console.log(this.time)
  301. },
  302. onLoad(options) {
  303. if ('params' in options) {
  304. this.objValue = JSON.parse(decodeURIComponent(options.params));
  305. // if (this.objValue.enginType == `old_renovation`) {
  306. // this.title = '旧改工程-庭院'
  307. // } else if (this.objValue.enginType == `new_built`) {
  308. // this.title = '新建工程-庭院'
  309. // }
  310. // uni.setNavigationBarTitle({
  311. // title: this.title
  312. // })
  313. }
  314. },
  315. methods: {
  316. //判断是否选择
  317. isEmpty(str) {
  318. return (!str || 0 === str.length);
  319. },
  320. handleSubmit(e) {
  321. this.time = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:${e.second}`;
  322. },
  323. //获取当前时间
  324. traversalTime(timestamp) {
  325. //timestamp(时间戳)是整数,否则要parseInt转换
  326. let time = new Date(timestamp);
  327. let y = time.getFullYear();
  328. let m = time.getMonth() + 1;
  329. let d = time.getDate();
  330. let h = time.getHours();
  331. let mm = time.getMinutes();
  332. let s = time.getSeconds();
  333. return y + '-' + this.addTimes(m) + '-' + this.addTimes(d) + ' ' + this.addTimes(h) + ':' + this.addTimes(
  334. mm) + ':' + this.addTimes(s);
  335. },
  336. addTimes(m) {
  337. return m < 10 ? '0' + m : m
  338. },
  339. // 打开picker
  340. openDatetimePicker() {
  341. this.$refs.myPicker.show();
  342. },
  343. // 关闭picker
  344. closeDatetimePicker() {
  345. this.$refs.myPicker.hide();
  346. },
  347. getUser() {
  348. getUserProfile().then(response => {
  349. this.user = response.data.user
  350. })
  351. },
  352. pickerShow(e, index) {
  353. this.SelectIndex = index;
  354. this.type = e; //赋值类型
  355. if (e == 'cz') { //材质
  356. this.open = true;
  357. getEnginMaterialQualityList("工业工程").then(response => {
  358. this.selectList = response.data;
  359. });
  360. } else if (e == 'gg') { //规格
  361. if (this.isEmpty(this.czggslList[index].cz.id)) {
  362. this.$modal.msg('请选择材质')
  363. // this.czggslList[index].cz = this.materialValue.id
  364. } else {
  365. this.open = true;
  366. this.selectList = this.materialList;
  367. }
  368. } else if (e == 'gclx') { //工程类型
  369. this.openDict = true;
  370. getDicts("industry_engin_type").then(response => {
  371. this.dictOptions = response.data;
  372. });
  373. } else if (e == 'gcmc') { //工程名称
  374. if (this.isEmpty(this.projectType.dictValue)) {
  375. this.$modal.msg('请选择工程类型')
  376. return
  377. }
  378. this.open = true;
  379. //请求
  380. console.log("sss", this.objValue.value)
  381. getengineeringNameList(this.projectType.dictValue, "1", this.objValue.value).then(response => {
  382. this.selectList = response.data;
  383. });
  384. }
  385. },
  386. chooseFile() {
  387. let _this = this;
  388. console.log('文件')
  389. uni.chooseMessageFile({
  390. // sizeType: ['album', 'camera'],
  391. type: 'all',
  392. success(resp) {
  393. resp.tempFiles.forEach((item, index) => {
  394. const task = uni.uploadFile({
  395. url: _this.$HTTP + `/obs`,
  396. filePath: item.path,
  397. name: 'file',
  398. formData: {},
  399. header: _this.headers,
  400. success: res => {
  401. // 判断是否json字符串,将其转为json格式
  402. console.log("结果", res)
  403. // let data = _this.$u.test.jsonString(res
  404. // .data) ? JSON.parse(res.data) : res.data;
  405. let data = JSON.parse(res.data);
  406. if (![200].includes(data.code)) {
  407. // this.uploadError(index, data);
  408. _this.$modal.msg(data.msg)
  409. } else {
  410. if (_this.progress === 100) {
  411. console.log('_this.progress', _this.progress)
  412. //console.log('data----', data)data
  413. console.log('res--', res)
  414. _this.fileArr.push({
  415. 'name': item.name,
  416. 'url': data.data.url
  417. })
  418. _this.fileNameArr.push(item.name)
  419. console.log('fileArr', _this.fileArr)
  420. _this.$modal.msg('上传成功!')
  421. }
  422. }
  423. },
  424. fail: e => {
  425. console.log(e)
  426. _this.$modal.msg('上传失败!')
  427. //_this.uploadError(index, e);
  428. },
  429. complete: res => {
  430. uni.hideLoading();
  431. _this.uploading = false;
  432. }
  433. });
  434. task.onProgressUpdate(res => {
  435. _this.progress = res.progress;
  436. console.log('onProgressUpdate', res)
  437. console.log('task.onProgressUpdate', _this.progress)
  438. uni.showLoading({
  439. title: '上传中'
  440. })
  441. if (_this.progress != 100) {
  442. _this.loading = false
  443. console.log('_this.loading false', _this.loading)
  444. } else {
  445. _this.loading = true
  446. console.log('_this.loading true', _this.loading)
  447. }
  448. });
  449. })
  450. },
  451. })
  452. },
  453. showPhoto(index) {
  454. uni.previewImage({
  455. current: index,
  456. urls: this.imgArr,
  457. })
  458. },
  459. removeFile(index) {
  460. uni.showModal({
  461. title: '提示',
  462. content: '是否删除该文件?',
  463. success: (res) => {
  464. if (res.confirm) {
  465. this.fileArr.splice(index, 1)
  466. this.fileNameArr.splice(index, 1)
  467. console.log('this.fileArr', this.fileArr)
  468. }
  469. }
  470. })
  471. },
  472. remove(index) {
  473. uni.showModal({
  474. title: '提示',
  475. content: '是否删除该图片或视频?',
  476. success: (res) => {
  477. if (res.confirm) {
  478. this.imgArr.splice(index, 1)
  479. console.log('this.imgarr', this.imgArr)
  480. // if (this.imgArr.length <= 0) {
  481. // this.photo = true;
  482. // }
  483. }
  484. }
  485. })
  486. },
  487. choose() {
  488. let _this = this;
  489. uni.showActionSheet({
  490. title: '上传',
  491. itemList: ['图片', '视频'],
  492. success: (res) => {
  493. console.log(res)
  494. if (res.tapIndex == 0) {
  495. this.chooseimage()
  496. } else {
  497. this.choosevideo()
  498. }
  499. }
  500. })
  501. },
  502. chooseimage() {
  503. let _this = this;
  504. console.log('图片', _this.headers)
  505. uni.chooseImage({
  506. sizeType: ['album', 'camera'],
  507. success(resp) {
  508. resp.tempFiles.forEach((item, index) => {
  509. const task = uni.uploadFile({
  510. url: _this.$HTTP + `/obs`,
  511. filePath: item.path,
  512. name: 'file',
  513. formData: {},
  514. header: _this.headers,
  515. success: res => {
  516. // 判断是否json字符串,将其转为json格式
  517. console.log("结果", res)
  518. // let data = _this.$u.test.jsonString(res
  519. // .data) ? JSON.parse(res.data) : res.data;
  520. let data = JSON.parse(res.data);
  521. if (![200].includes(data.code)) {
  522. // this.uploadError(index, data);
  523. _this.$modal.msg(data.msg)
  524. } else {
  525. if (_this.progress === 100) {
  526. console.log('_this.progress', _this.progress)
  527. //console.log('data----', data)data
  528. console.log('res--', res)
  529. _this.imgArr.push(data.data.url)
  530. console.log('imgArr', _this.imgArr)
  531. _this.$modal.msg('上传成功!')
  532. //_this.photo = false;
  533. }
  534. }
  535. },
  536. fail: e => {
  537. console.log(e)
  538. _this.$modal.msg('上传失败!')
  539. //_this.uploadError(index, e);
  540. },
  541. complete: res => {
  542. uni.hideLoading();
  543. _this.uploading = false;
  544. }
  545. });
  546. task.onProgressUpdate(res => {
  547. _this.progress = res.progress;
  548. console.log('onProgressUpdate', res)
  549. console.log('task.onProgressUpdate', _this.progress)
  550. uni.showLoading({
  551. title: '上传中'
  552. })
  553. if (_this.progress != 100) {
  554. _this.loading = false
  555. console.log('_this.loading false', _this.loading)
  556. } else {
  557. _this.loading = true
  558. console.log('_this.loading true', _this.loading)
  559. }
  560. });
  561. })
  562. },
  563. })
  564. },
  565. choosevideo() {
  566. let _this = this;
  567. console.log('视频')
  568. uni.chooseVideo({
  569. sourceType: ['album', 'camera'],
  570. maxDuration: 30,
  571. success(resp) {
  572. const task = uni.uploadFile({
  573. url: _this.$HTTP + `/obs`,
  574. filePath: resp.tempFilePath,
  575. name: 'file',
  576. formData: {},
  577. header: _this.headers,
  578. success: res => {
  579. // 判断是否json字符串,将其转为json格式
  580. let data = JSON.parse(res.data);
  581. if (![200].includes(res.statusCode)) {
  582. this.uploadError(index, data);
  583. } else {
  584. //上传成功
  585. if (_this.progress === 100) {
  586. console.log('_this.progress', _this.progress)
  587. _this.imgArr.push(data.data.url)
  588. console.log('imgArr', _this.imgArr)
  589. _this.$modal.msg('上传成功!')
  590. //_this.photo = false;
  591. }
  592. }
  593. },
  594. fail: e => {
  595. _this.$modal.msg('上传失败!')
  596. this.uploadError(index, e);
  597. },
  598. complete: res => {
  599. uni.hideLoading();
  600. _this.uploading = false;
  601. }
  602. });
  603. task.onProgressUpdate(res => {
  604. _this.progress = res.progress;
  605. console.log('onProgressUpdate', res)
  606. uni.showLoading({
  607. title: '上传中'
  608. })
  609. if (_this.progress != 100) {
  610. _this.loadingFile = false
  611. console.log('_this.loading false', _this.loading)
  612. } else {
  613. _this.loadingFile = true
  614. console.log('_this.loading true', _this.loading)
  615. }
  616. });
  617. },
  618. })
  619. },
  620. changeSelectDict(item, index) {
  621. this.openDict = false;
  622. this.projectType = item
  623. this.projectName = ''; //重置工程名称
  624. this.jlPhoneValue = ''; //重置监理电话
  625. this.jlfzrValue = ''; //重置监理负责人
  626. this.jldwValue = ''; //重置监理单位
  627. this.sjPhoneValue = ''; //重置设计电话
  628. this.sjfzrValue = ''; //重置设计负责人
  629. this.sjdwValue = ''; //重置设计单位
  630. this.xcfzrValue = ''; //重置现场负责人
  631. this.xmfzrValue = ''; //重置项目负责人
  632. this.jsdwValue = ''; //重置建设单位
  633. this.enginId = ''; //重置工程id
  634. this.fileArr = ''
  635. this.createTime = '';
  636. this.infonId = '';
  637. },
  638. changeSelect(item, index) {
  639. // this.index = index;
  640. // this.address = item.communityName;
  641. this.open = false;
  642. if (this.type == 'cz') {
  643. this.materialValue = item;
  644. this.specificationValue = ''; //重置规格
  645. //根据材质ID 获取规格数据
  646. getEnginSpecificationsList(item.id).then(res => {
  647. this.materialList = res.data
  648. this.czggslList[this.SelectIndex].cz.id = this.materialValue.id
  649. this.czggslList[this.SelectIndex].cz.name = this.materialValue.name
  650. })
  651. } else if (this.type == 'gg') {
  652. this.specificationValue = item;
  653. this.czggslList[this.SelectIndex].gg.id = this.specificationValue.id
  654. this.czggslList[this.SelectIndex].gg.name = this.specificationValue.name
  655. } else if (this.type == 'gcmc') {
  656. this.projectName = item
  657. //根据工程id 获取工程信息
  658. uni.showLoading({
  659. title: '加载中'
  660. })
  661. getEngineeringDetails(item.id).then(response => {
  662. uni.hideLoading();
  663. console.log("res", response)
  664. // this.enginList = response.data
  665. this.jlPhoneValue = response.data.supervisionPhone; //监理电话
  666. this.jlfzrValue = response.data.supervisionHead; //监理负责人
  667. this.jldwValue = response.data.supervisionUnit; //监理单位
  668. this.sjPhoneValue = response.data.designPhone; //设计电话
  669. this.sjfzrValue = response.data.designHead; //设计负责人
  670. this.sjdwValue = response.data.designUnit; //设计单位
  671. this.xcfzrValue = response.data.sceneHead; //现场负责人
  672. this.xmfzrValue = response.data.projectHead; //项目负责人
  673. this.jsdwValue = response.data.constructUnit; //建设单位
  674. this.enginId = response.data.id; //工程id
  675. this.fileArr = response.data.pics
  676. this.createTime = response.data.createTime;
  677. this.infonId = response.data.zEngineeringNodeBoList[0].zEngineeringInfoBoList[0].id
  678. });
  679. }
  680. },
  681. //关闭弹窗
  682. close(e) {
  683. this.open = false
  684. },
  685. //关闭弹窗
  686. closeDict(e) {
  687. this.openDict = false
  688. },
  689. chooseModel(url, name) {
  690. this.cancelText = '复制';
  691. this.confirmText = "下载";
  692. this.titleText = "温馨提示"
  693. this.popupText = "下载或者复制链接";
  694. this.show_loding = true;
  695. this.fileName = name;
  696. this.fileUrl = url; //文件名称和下载地址赋值
  697. },
  698. //取消按钮
  699. cancel_loding() {
  700. let _this = this;
  701. _this.show_loding = false;
  702. console.log("复制")
  703. if (!_this.isEmpty(_this.fileUrl)) {
  704. console.log(_this.fileUrl)
  705. console.log(_this.fileName)
  706. uni.setClipboardData({
  707. data: _this.fileUrl,
  708. success() {
  709. uni.showToast({
  710. title: '已复制' + _this.fileName + '地址成功 请在浏览器打开',
  711. icon: 'none'
  712. });
  713. },
  714. fail(e) {
  715. console.log("失败", e)
  716. uni.showToast({
  717. title: '复制失败',
  718. icon: 'none'
  719. });
  720. }
  721. });
  722. }
  723. },
  724. //确定按钮
  725. confirm_loding() {
  726. this.show_loding = false;
  727. console.log("下载")
  728. this.download(this.fileUrl, this.fileName);
  729. },
  730. getDownLoadFilePath() {
  731. let cachePath = `${uni.env.USER_DATA_PATH}/downloads`
  732. let fm = uni.getFileSystemManager()
  733. try {
  734. // 访问成功则存在
  735. fm.accessSync(cachePath)
  736. } catch (error) {
  737. // 不存在则新建
  738. fm.mkdirSync(cachePath, true)
  739. }
  740. return cachePath
  741. },
  742. download(url, name) {
  743. let savePath = this.getDownLoadFilePath();
  744. console.log('点击下载', url);
  745. console.log('点击下载333', savePath);
  746. //var savePath = uni.env.USER_DATA_PATH + '/savePath'
  747. uni.downloadFile({
  748. url: url,
  749. success: response => {
  750. if (response.statusCode === 200) {
  751. console.log("数据", response)
  752. uni.getFileSystemManager().saveFile({
  753. tempFilePath: response.tempFilePath,
  754. filePath: `${savePath}/${name}`,
  755. success: (resData) => {
  756. console.log('保存路径', resData.savedFilePath)
  757. console.log("dd", resData)
  758. uni.showToast({
  759. title: '下载成功'
  760. })
  761. },
  762. fail: error => {
  763. console.log('error: ', error)
  764. }
  765. })
  766. }
  767. }
  768. })
  769. },
  770. //历史
  771. history() {
  772. if (this.isEmpty(this.projectType.dictValue)) {
  773. this.$modal.msg('请选择工程类型')
  774. return
  775. }
  776. if (this.isEmpty(this.projectName.id)) {
  777. this.$modal.msg('请选择工程名称')
  778. return
  779. }
  780. getEngineeringHistoryList(this.enginId, this.objValue.value).then(response => {
  781. console.log("历史", response)
  782. this.historyList = response.data
  783. if (response.data.zEngineeringNodeBo.zEngineeringInfoBoList != null) {
  784. this.$refs.refShare.handleShowShare();
  785. } else {
  786. this.$modal.msg("暂无历史信息")
  787. }
  788. });
  789. },
  790. submit() {
  791. console.log("文件", this.fileArr)
  792. if (this.isEmpty(this.projectType.dictValue)) {
  793. this.$modal.msg('请选择工程类型')
  794. return
  795. }
  796. if (this.isEmpty(this.projectName.id)) {
  797. this.$modal.msg('请选择工程名称')
  798. return
  799. }
  800. // if (this.isEmpty(this.jsdwValue)) {
  801. // this.$modal.msg('建设单位不能为空')
  802. // return
  803. // }
  804. // if (this.isEmpty(this.xmfzrValue)) {
  805. // this.$modal.msg('项目负责人不能为空')
  806. // return
  807. // }
  808. // if (this.isEmpty(this.xcfzrValue)) {
  809. // this.$modal.msg('现场负责人不能为空')
  810. // return
  811. // }
  812. // if (this.isEmpty(this.sjdwValue)) {
  813. // this.$modal.msg('设计单位不能为空')
  814. // return
  815. // }
  816. // if (this.isEmpty(this.sjfzrValue)) {
  817. // this.$modal.msg('设计负责人不能为空')
  818. // return
  819. // }
  820. // if (this.isEmpty(this.sjPhoneValue)) {
  821. // this.$modal.msg('设计联系电话不能为空')
  822. // return
  823. // }
  824. // if (!this.$validation.mobile(this.sjPhoneValue)) {
  825. // this.$modal.msg('设计联系电话格式错误')
  826. // return
  827. // }
  828. // if (this.isEmpty(this.jldwValue)) {
  829. // this.$modal.msg('监理单位不能为空')
  830. // return
  831. // }
  832. // if (this.isEmpty(this.jlfzrValue)) {
  833. // this.$modal.msg('监理负责人不能为空')
  834. // return
  835. // }
  836. // if (this.isEmpty(this.jlPhoneValue)) {
  837. // this.$modal.msg('监理联系电话不能为空')
  838. // return
  839. // }
  840. // if (!this.$validation.mobile(this.jlPhoneValue)) {
  841. // this.$modal.msg('监理联系电话格式错误')
  842. // return
  843. // }
  844. // if (this.fileArr.length <= 0) {
  845. // this.$modal.msg('请上传文件')
  846. // } else if (this.loadingFile == false) {
  847. // this.$modal.msg('文件未上传完毕,无法提交!')
  848. // }
  849. try {
  850. //console.log("刚开始", this.czggslList);
  851. this.czggslList.forEach((list) => {
  852. if (this.isEmpty(list.cz.id)) {
  853. this.$modal.msg('材质不能为空')
  854. throw new Error('End Loop')
  855. }
  856. if (this.isEmpty(list.gg.id)) {
  857. this.$modal.msg('规格不能为空')
  858. throw new Error('End Loop')
  859. }
  860. if (this.isEmpty(list.sl)) {
  861. this.$modal.msg('数量不能为空')
  862. throw new Error('End Loop')
  863. }
  864. })
  865. } catch (e) {
  866. if (e.message === 'End Loop') throw e
  867. }
  868. if (this.imgArr.length <= 0) {
  869. this.$modal.msg('请上传照片或视频')
  870. return
  871. }
  872. if (this.loading == false) {
  873. this.$modal.msg('照片或视频未上传完毕,无法提交!')
  874. return
  875. }
  876. this.zEngineeringMaterialBo = [];
  877. this.czggslList.forEach((list) => {
  878. this.zEngineeringMaterialBo.push({
  879. materialQuality: list.cz.id,
  880. specifications: list.gg.id,
  881. number: list.sl
  882. })
  883. }),
  884. console.log("数据", this.zEngineeringMaterialBo)
  885. let param = {
  886. //files: this.fileArr, //文件
  887. id: this.enginId, //工程id
  888. type: '1', // 用来区分工业工程=1、市政工程=2
  889. enginName: this.projectName.name, //工程名称
  890. enginType: this.projectType.dictValue, // 工程类型
  891. constructUnit: this.jsdwValue, // 建筑单位
  892. projectHead: this.xmfzrValue, // 项目负责人
  893. sceneHead: this.xcfzrValue, // 现场负责人
  894. designUnit: this.sjdwValue, // 设计单位
  895. designHead: this.sjfzrValue, // 设计负责人
  896. designPhone: this.sjPhoneValue, // 设计联系电话
  897. supervisionUnit: this.jldwValue, // 监理单位
  898. supervisionHead: this.jlfzrValue, // 监理负责人
  899. supervisionPhone: this.jlPhoneValue, // 监理联系电话
  900. enginClassification: this.objValue.value, // 工程分类 上一页面传过来的
  901. zEngineeringNodeBo: {
  902. createTime: this.createTime,
  903. type: '工业工程', // 写死
  904. zEngineeringInfoBo: {
  905. engInfoId: this.infonId,
  906. constructTime: this.time, //施工时间
  907. zEngiineeringPhotoBoList: this.imgArr, //照片集合
  908. zEngineeringMaterialBo: this.zEngineeringMaterialBo // 用料对象
  909. }
  910. }
  911. }
  912. Submitengineering(param).then(res => {
  913. if (res.code == '200') {
  914. uni.showToast({
  915. title: res.msg,
  916. icon: 'none',
  917. //显示持续时间为 3秒
  918. duration: 2000
  919. });
  920. setTimeout(function() {
  921. uni.navigateBack();
  922. }, 1000)
  923. }
  924. })
  925. }
  926. }
  927. }
  928. </script>
  929. <style>
  930. .container {
  931. display: flex;
  932. margin-left: 10px;
  933. margin-top: 10px;
  934. margin-right: 10px;
  935. align-items: flex-start;
  936. justify-content: space-between;
  937. }
  938. .text {
  939. font-size: 16px;
  940. color: #333;
  941. }
  942. .background {
  943. border: 15px solid hsla(0, 0%, 100%, .5);
  944. background: white;
  945. background-clip: padding-box;
  946. /*从padding开始往外面裁剪背景*/
  947. }
  948. .btn {
  949. margin-top: 40px;
  950. margin-right: 20px;
  951. margin-bottom: 120px;
  952. margin-left: 20px;
  953. height: 45px;
  954. }
  955. .number {
  956. display: flex;
  957. /* 水平居中显示子元素 */
  958. align-items: flex-start;
  959. /* 垂直居中显示子元素 */
  960. justify-content: space-between;
  961. /* 左右间距等于间距大小 */
  962. padding: 10px;
  963. /* 设置padding以提高视觉效果 */
  964. }
  965. .textarea {
  966. margin-top: 10upx;
  967. width: 100%;
  968. border: 1rpx solid red;
  969. min-height: 100upx;
  970. line-height: 20px;
  971. }
  972. page {
  973. background: #f2f2f2;
  974. }
  975. .flex-x {
  976. display: flex;
  977. align-items: center;
  978. }
  979. .template_title,
  980. .template_title1,
  981. .template_title_list {
  982. height: 90rpx;
  983. background: #fff;
  984. justify-content: space-between;
  985. padding: 0 30rpx;
  986. box-sizing: border-box;
  987. }
  988. .template_title1 {
  989. background: none;
  990. }
  991. .template_title_list {
  992. margin-bottom: 4rpx;
  993. }
  994. .template_title>view,
  995. .template_title1>view {
  996. font-size: 32rpx;
  997. color: #8f8f8f;
  998. flex-shrink: 0;
  999. margin-right: 20rpx;
  1000. }
  1001. .template_title>input {
  1002. font-size: 28rpx;
  1003. color: #808080;
  1004. text-align: right;
  1005. flex-grow: 1;
  1006. }
  1007. /* 添加内容 */
  1008. .add_con>text {
  1009. font-size: 40rpx;
  1010. color: #f16765;
  1011. display: block;
  1012. margin-right: 20rpx;
  1013. margin-left: 10rpx;
  1014. line-height: 44rpx;
  1015. }
  1016. .add_con>view {
  1017. font-size: 32rpx;
  1018. color: #7885cb;
  1019. }
  1020. /* 删除内容 */
  1021. .del {
  1022. font-size: 32rpx;
  1023. color: #f16765;
  1024. margin-right: 14rpx;
  1025. padding: 20rpx;
  1026. }
  1027. input {
  1028. flex-grow: 1;
  1029. font-size: 28rpx;
  1030. color: #808080;
  1031. }
  1032. .btn {
  1033. margin-top: 100rpx;
  1034. }
  1035. </style>