enginproject.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178
  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"></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. getEngineeringDetails(item.id).then(response => {
  659. console.log("res", response)
  660. // this.enginList = response.data
  661. this.jlPhoneValue = response.data.supervisionPhone; //监理电话
  662. this.jlfzrValue = response.data.supervisionHead; //监理负责人
  663. this.jldwValue = response.data.supervisionUnit; //监理单位
  664. this.sjPhoneValue = response.data.designPhone; //设计电话
  665. this.sjfzrValue = response.data.designHead; //设计负责人
  666. this.sjdwValue = response.data.designUnit; //设计单位
  667. this.xcfzrValue = response.data.sceneHead; //现场负责人
  668. this.xmfzrValue = response.data.projectHead; //项目负责人
  669. this.jsdwValue = response.data.constructUnit; //建设单位
  670. this.enginId = response.data.id; //工程id
  671. this.fileArr = response.data.pics
  672. this.createTime = response.data.createTime;
  673. this.infonId = response.data.zEngineeringNodeBoList[0].zEngineeringInfoBoList[0].id
  674. });
  675. }
  676. },
  677. //关闭弹窗
  678. close(e) {
  679. this.open = false
  680. },
  681. //关闭弹窗
  682. closeDict(e) {
  683. this.openDict = false
  684. },
  685. chooseModel(url, name) {
  686. this.cancelText = '复制';
  687. this.confirmText = "下载";
  688. this.titleText = "温馨提示"
  689. this.popupText = "下载或者复制链接";
  690. this.show_loding = true;
  691. this.fileName = name;
  692. this.fileUrl = url; //文件名称和下载地址赋值
  693. },
  694. //取消按钮
  695. cancel_loding() {
  696. let _this = this;
  697. _this.show_loding = false;
  698. console.log("复制")
  699. if (!_this.isEmpty(_this.fileUrl)) {
  700. console.log(_this.fileUrl)
  701. console.log(_this.fileName)
  702. uni.setClipboardData({
  703. data: _this.fileUrl,
  704. success() {
  705. uni.showToast({
  706. title: '已复制' + _this.fileName + '地址成功 请在浏览器打开',
  707. icon: 'none'
  708. });
  709. },
  710. fail(e) {
  711. console.log("失败", e)
  712. uni.showToast({
  713. title: '复制失败',
  714. icon: 'none'
  715. });
  716. }
  717. });
  718. }
  719. },
  720. //确定按钮
  721. confirm_loding() {
  722. this.show_loding = false;
  723. console.log("下载")
  724. this.download(this.fileUrl, this.fileName);
  725. },
  726. getDownLoadFilePath() {
  727. let cachePath = `${uni.env.USER_DATA_PATH}/downloads`
  728. let fm = uni.getFileSystemManager()
  729. try {
  730. // 访问成功则存在
  731. fm.accessSync(cachePath)
  732. } catch (error) {
  733. // 不存在则新建
  734. fm.mkdirSync(cachePath, true)
  735. }
  736. return cachePath
  737. },
  738. download(url, name) {
  739. let savePath = this.getDownLoadFilePath();
  740. console.log('点击下载', url);
  741. console.log('点击下载333', savePath);
  742. //var savePath = uni.env.USER_DATA_PATH + '/savePath'
  743. uni.downloadFile({
  744. url: url,
  745. success: response => {
  746. if (response.statusCode === 200) {
  747. console.log("数据", response)
  748. uni.getFileSystemManager().saveFile({
  749. tempFilePath: response.tempFilePath,
  750. filePath: `${savePath}/${name}`,
  751. success: (resData) => {
  752. console.log('保存路径', resData.savedFilePath)
  753. console.log("dd", resData)
  754. uni.showToast({
  755. title: '下载成功' + resData.savedFilePath
  756. })
  757. },
  758. fail: error => {
  759. console.log('error: ', error)
  760. }
  761. })
  762. }
  763. }
  764. })
  765. },
  766. //历史
  767. history() {
  768. if (this.isEmpty(this.projectType.dictValue)) {
  769. this.$modal.msg('请选择工程类型')
  770. return
  771. }
  772. if (this.isEmpty(this.projectName.id)) {
  773. this.$modal.msg('请选择工程名称')
  774. return
  775. }
  776. getEngineeringHistoryList(this.enginId, this.objValue.value).then(response => {
  777. console.log("历史", response)
  778. this.historyList = response.data
  779. if (response.data.zEngineeringNodeBo != null) {
  780. this.$refs.refShare.handleShowShare();
  781. } else {
  782. this.$modal.msg("暂无历史信息")
  783. }
  784. });
  785. },
  786. submit() {
  787. console.log("文件", this.fileArr)
  788. if (this.isEmpty(this.projectType.dictValue)) {
  789. this.$modal.msg('请选择工程类型')
  790. return
  791. }
  792. if (this.isEmpty(this.projectName.id)) {
  793. this.$modal.msg('请选择工程名称')
  794. return
  795. }
  796. // if (this.isEmpty(this.jsdwValue)) {
  797. // this.$modal.msg('建设单位不能为空')
  798. // return
  799. // }
  800. // if (this.isEmpty(this.xmfzrValue)) {
  801. // this.$modal.msg('项目负责人不能为空')
  802. // return
  803. // }
  804. // if (this.isEmpty(this.xcfzrValue)) {
  805. // this.$modal.msg('现场负责人不能为空')
  806. // return
  807. // }
  808. // if (this.isEmpty(this.sjdwValue)) {
  809. // this.$modal.msg('设计单位不能为空')
  810. // return
  811. // }
  812. // if (this.isEmpty(this.sjfzrValue)) {
  813. // this.$modal.msg('设计负责人不能为空')
  814. // return
  815. // }
  816. // if (this.isEmpty(this.sjPhoneValue)) {
  817. // this.$modal.msg('设计联系电话不能为空')
  818. // return
  819. // }
  820. // if (!this.$validation.mobile(this.sjPhoneValue)) {
  821. // this.$modal.msg('设计联系电话格式错误')
  822. // return
  823. // }
  824. // if (this.isEmpty(this.jldwValue)) {
  825. // this.$modal.msg('监理单位不能为空')
  826. // return
  827. // }
  828. // if (this.isEmpty(this.jlfzrValue)) {
  829. // this.$modal.msg('监理负责人不能为空')
  830. // return
  831. // }
  832. // if (this.isEmpty(this.jlPhoneValue)) {
  833. // this.$modal.msg('监理联系电话不能为空')
  834. // return
  835. // }
  836. // if (!this.$validation.mobile(this.jlPhoneValue)) {
  837. // this.$modal.msg('监理联系电话格式错误')
  838. // return
  839. // }
  840. // if (this.fileArr.length <= 0) {
  841. // this.$modal.msg('请上传文件')
  842. // } else if (this.loadingFile == false) {
  843. // this.$modal.msg('文件未上传完毕,无法提交!')
  844. // }
  845. try {
  846. //console.log("刚开始", this.czggslList);
  847. this.czggslList.forEach((list) => {
  848. if (this.isEmpty(list.cz.id)) {
  849. this.$modal.msg('材质不能为空')
  850. throw new Error('End Loop')
  851. }
  852. if (this.isEmpty(list.gg.id)) {
  853. this.$modal.msg('规格不能为空')
  854. throw new Error('End Loop')
  855. }
  856. if (this.isEmpty(list.sl)) {
  857. this.$modal.msg('数量不能为空')
  858. throw new Error('End Loop')
  859. }
  860. })
  861. } catch (e) {
  862. if (e.message === 'End Loop') throw e
  863. }
  864. if (this.imgArr.length <= 0) {
  865. this.$modal.msg('请上传照片或视频')
  866. return
  867. }
  868. if (this.loading == false) {
  869. this.$modal.msg('照片或视频未上传完毕,无法提交!')
  870. return
  871. }
  872. this.zEngineeringMaterialBo = [];
  873. this.czggslList.forEach((list) => {
  874. this.zEngineeringMaterialBo.push({
  875. materialQuality: list.cz.id,
  876. specifications: list.gg.id,
  877. number: list.sl
  878. })
  879. }),
  880. console.log("数据", this.zEngineeringMaterialBo)
  881. let param = {
  882. files: this.fileArr, //文件
  883. id: this.enginId, //工程id
  884. type: '1', // 用来区分工业工程=1、市政工程=2
  885. enginName: this.projectName.name, //工程名称
  886. enginType: this.projectType.dictValue, // 工程类型
  887. constructUnit: this.jsdwValue, // 建筑单位
  888. projectHead: this.xmfzrValue, // 项目负责人
  889. sceneHead: this.xcfzrValue, // 现场负责人
  890. designUnit: this.sjdwValue, // 设计单位
  891. designHead: this.sjfzrValue, // 设计负责人
  892. designPhone: this.sjPhoneValue, // 设计联系电话
  893. supervisionUnit: this.jldwValue, // 监理单位
  894. supervisionHead: this.jlfzrValue, // 监理负责人
  895. supervisionPhone: this.jlPhoneValue, // 监理联系电话
  896. enginClassification: this.objValue.value, // 工程分类 上一页面传过来的
  897. zEngineeringNodeBo: {
  898. createTime: this.createTime,
  899. type: '工业工程', // 写死
  900. zEngineeringInfoBo: {
  901. engInfoId: this.infonId,
  902. constructTime: this.time, //施工时间
  903. zEngiineeringPhotoBoList: this.imgArr, //照片集合
  904. zEngineeringMaterialBo: this.zEngineeringMaterialBo // 用料对象
  905. }
  906. }
  907. }
  908. Submitengineering(param).then(res => {
  909. if (res.code == '200') {
  910. uni.showToast({
  911. title: res.msg,
  912. icon: 'none',
  913. //显示持续时间为 3秒
  914. duration: 2000
  915. });
  916. setTimeout(function() {
  917. uni.navigateBack();
  918. }, 1000)
  919. }
  920. })
  921. }
  922. }
  923. }
  924. </script>
  925. <style>
  926. .container {
  927. display: flex;
  928. margin-left: 10px;
  929. margin-top: 10px;
  930. margin-right: 10px;
  931. align-items: flex-start;
  932. justify-content: space-between;
  933. }
  934. .text {
  935. font-size: 16px;
  936. color: #333;
  937. }
  938. .background {
  939. border: 15px solid hsla(0, 0%, 100%, .5);
  940. background: white;
  941. background-clip: padding-box;
  942. /*从padding开始往外面裁剪背景*/
  943. }
  944. .btn {
  945. margin-top: 40px;
  946. margin-right: 20px;
  947. margin-bottom: 120px;
  948. margin-left: 20px;
  949. height: 45px;
  950. }
  951. .number {
  952. display: flex;
  953. /* 水平居中显示子元素 */
  954. align-items: flex-start;
  955. /* 垂直居中显示子元素 */
  956. justify-content: space-between;
  957. /* 左右间距等于间距大小 */
  958. padding: 10px;
  959. /* 设置padding以提高视觉效果 */
  960. }
  961. .textarea {
  962. margin-top: 10upx;
  963. width: 100%;
  964. border: 1rpx solid red;
  965. min-height: 100upx;
  966. line-height: 20px;
  967. }
  968. page {
  969. background: #f2f2f2;
  970. }
  971. .flex-x {
  972. display: flex;
  973. align-items: center;
  974. }
  975. .template_title,
  976. .template_title1,
  977. .template_title_list {
  978. height: 90rpx;
  979. background: #fff;
  980. justify-content: space-between;
  981. padding: 0 30rpx;
  982. box-sizing: border-box;
  983. }
  984. .template_title1 {
  985. background: none;
  986. }
  987. .template_title_list {
  988. margin-bottom: 4rpx;
  989. }
  990. .template_title>view,
  991. .template_title1>view {
  992. font-size: 32rpx;
  993. color: #8f8f8f;
  994. flex-shrink: 0;
  995. margin-right: 20rpx;
  996. }
  997. .template_title>input {
  998. font-size: 28rpx;
  999. color: #808080;
  1000. text-align: right;
  1001. flex-grow: 1;
  1002. }
  1003. /* 添加内容 */
  1004. .add_con>text {
  1005. font-size: 40rpx;
  1006. color: #f16765;
  1007. display: block;
  1008. margin-right: 20rpx;
  1009. margin-left: 10rpx;
  1010. line-height: 44rpx;
  1011. }
  1012. .add_con>view {
  1013. font-size: 32rpx;
  1014. color: #7885cb;
  1015. }
  1016. /* 删除内容 */
  1017. .del {
  1018. font-size: 32rpx;
  1019. color: #f16765;
  1020. margin-right: 14rpx;
  1021. padding: 20rpx;
  1022. }
  1023. input {
  1024. flex-grow: 1;
  1025. font-size: 28rpx;
  1026. color: #808080;
  1027. }
  1028. .btn {
  1029. margin-top: 100rpx;
  1030. }
  1031. </style>