enginproject.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  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. getengineeringNameList(this.projectType.dictValue, "1").then(response => {
  381. this.selectList = response.data;
  382. });
  383. }
  384. },
  385. chooseFile() {
  386. let _this = this;
  387. console.log('文件')
  388. uni.chooseMessageFile({
  389. // sizeType: ['album', 'camera'],
  390. type: 'all',
  391. success(resp) {
  392. resp.tempFiles.forEach((item, index) => {
  393. const task = uni.uploadFile({
  394. url: _this.$HTTP + `/obs`,
  395. filePath: item.path,
  396. name: 'file',
  397. formData: {},
  398. header: _this.headers,
  399. success: res => {
  400. // 判断是否json字符串,将其转为json格式
  401. console.log("结果", res)
  402. // let data = _this.$u.test.jsonString(res
  403. // .data) ? JSON.parse(res.data) : res.data;
  404. let data = JSON.parse(res.data);
  405. if (![200].includes(data.code)) {
  406. // this.uploadError(index, data);
  407. _this.$modal.msg(data.msg)
  408. } else {
  409. if (_this.progress === 100) {
  410. console.log('_this.progress', _this.progress)
  411. //console.log('data----', data)data
  412. console.log('res--', res)
  413. _this.fileArr.push({
  414. 'name': item.name,
  415. 'url': data.data.url
  416. })
  417. _this.fileNameArr.push(item.name)
  418. console.log('fileArr', _this.fileArr)
  419. _this.$modal.msg('上传成功!')
  420. }
  421. }
  422. },
  423. fail: e => {
  424. console.log(e)
  425. _this.$modal.msg('上传失败!')
  426. //_this.uploadError(index, e);
  427. },
  428. complete: res => {
  429. uni.hideLoading();
  430. _this.uploading = false;
  431. }
  432. });
  433. task.onProgressUpdate(res => {
  434. _this.progress = res.progress;
  435. console.log('onProgressUpdate', res)
  436. console.log('task.onProgressUpdate', _this.progress)
  437. uni.showLoading({
  438. title: '上传中'
  439. })
  440. if (_this.progress != 100) {
  441. _this.loading = false
  442. console.log('_this.loading false', _this.loading)
  443. } else {
  444. _this.loading = true
  445. console.log('_this.loading true', _this.loading)
  446. }
  447. });
  448. })
  449. },
  450. })
  451. },
  452. showPhoto(index) {
  453. uni.previewImage({
  454. current: index,
  455. urls: this.imgArr,
  456. })
  457. },
  458. removeFile(index) {
  459. uni.showModal({
  460. title: '提示',
  461. content: '是否删除该文件?',
  462. success: (res) => {
  463. if (res.confirm) {
  464. this.fileArr.splice(index, 1)
  465. this.fileNameArr.splice(index, 1)
  466. console.log('this.fileArr', this.fileArr)
  467. }
  468. }
  469. })
  470. },
  471. remove(index) {
  472. uni.showModal({
  473. title: '提示',
  474. content: '是否删除该图片或视频?',
  475. success: (res) => {
  476. if (res.confirm) {
  477. this.imgArr.splice(index, 1)
  478. console.log('this.imgarr', this.imgArr)
  479. // if (this.imgArr.length <= 0) {
  480. // this.photo = true;
  481. // }
  482. }
  483. }
  484. })
  485. },
  486. choose() {
  487. let _this = this;
  488. uni.showActionSheet({
  489. title: '上传',
  490. itemList: ['图片', '视频'],
  491. success: (res) => {
  492. console.log(res)
  493. if (res.tapIndex == 0) {
  494. this.chooseimage()
  495. } else {
  496. this.choosevideo()
  497. }
  498. }
  499. })
  500. },
  501. chooseimage() {
  502. let _this = this;
  503. console.log('图片', _this.headers)
  504. uni.chooseImage({
  505. sizeType: ['album', 'camera'],
  506. success(resp) {
  507. resp.tempFiles.forEach((item, index) => {
  508. const task = uni.uploadFile({
  509. url: _this.$HTTP + `/obs`,
  510. filePath: item.path,
  511. name: 'file',
  512. formData: {},
  513. header: _this.headers,
  514. success: res => {
  515. // 判断是否json字符串,将其转为json格式
  516. console.log("结果", res)
  517. // let data = _this.$u.test.jsonString(res
  518. // .data) ? JSON.parse(res.data) : res.data;
  519. let data = JSON.parse(res.data);
  520. if (![200].includes(data.code)) {
  521. // this.uploadError(index, data);
  522. _this.$modal.msg(data.msg)
  523. } else {
  524. if (_this.progress === 100) {
  525. console.log('_this.progress', _this.progress)
  526. //console.log('data----', data)data
  527. console.log('res--', res)
  528. _this.imgArr.push(data.data.url)
  529. console.log('imgArr', _this.imgArr)
  530. _this.$modal.msg('上传成功!')
  531. //_this.photo = false;
  532. }
  533. }
  534. },
  535. fail: e => {
  536. console.log(e)
  537. _this.$modal.msg('上传失败!')
  538. //_this.uploadError(index, e);
  539. },
  540. complete: res => {
  541. uni.hideLoading();
  542. _this.uploading = false;
  543. }
  544. });
  545. task.onProgressUpdate(res => {
  546. _this.progress = res.progress;
  547. console.log('onProgressUpdate', res)
  548. console.log('task.onProgressUpdate', _this.progress)
  549. uni.showLoading({
  550. title: '上传中'
  551. })
  552. if (_this.progress != 100) {
  553. _this.loading = false
  554. console.log('_this.loading false', _this.loading)
  555. } else {
  556. _this.loading = true
  557. console.log('_this.loading true', _this.loading)
  558. }
  559. });
  560. })
  561. },
  562. })
  563. },
  564. choosevideo() {
  565. let _this = this;
  566. console.log('视频')
  567. uni.chooseVideo({
  568. sourceType: ['album', 'camera'],
  569. maxDuration: 30,
  570. success(resp) {
  571. const task = uni.uploadFile({
  572. url: _this.$HTTP + `/obs`,
  573. filePath: resp.tempFilePath,
  574. name: 'file',
  575. formData: {},
  576. header: _this.headers,
  577. success: res => {
  578. // 判断是否json字符串,将其转为json格式
  579. let data = JSON.parse(res.data);
  580. if (![200].includes(res.statusCode)) {
  581. this.uploadError(index, data);
  582. } else {
  583. //上传成功
  584. if (_this.progress === 100) {
  585. console.log('_this.progress', _this.progress)
  586. _this.imgArr.push(data.data.url)
  587. console.log('imgArr', _this.imgArr)
  588. _this.$modal.msg('上传成功!')
  589. //_this.photo = false;
  590. }
  591. }
  592. },
  593. fail: e => {
  594. _this.$modal.msg('上传失败!')
  595. this.uploadError(index, e);
  596. },
  597. complete: res => {
  598. uni.hideLoading();
  599. _this.uploading = false;
  600. }
  601. });
  602. task.onProgressUpdate(res => {
  603. _this.progress = res.progress;
  604. console.log('onProgressUpdate', res)
  605. uni.showLoading({
  606. title: '上传中'
  607. })
  608. if (_this.progress != 100) {
  609. _this.loadingFile = false
  610. console.log('_this.loading false', _this.loading)
  611. } else {
  612. _this.loadingFile = true
  613. console.log('_this.loading true', _this.loading)
  614. }
  615. });
  616. },
  617. })
  618. },
  619. changeSelectDict(item, index) {
  620. this.openDict = false;
  621. this.projectType = item
  622. this.projectName = ''; //重置工程名称
  623. this.jlPhoneValue = ''; //重置监理电话
  624. this.jlfzrValue = ''; //重置监理负责人
  625. this.jldwValue = ''; //重置监理单位
  626. this.sjPhoneValue = ''; //重置设计电话
  627. this.sjfzrValue = ''; //重置设计负责人
  628. this.sjdwValue = ''; //重置设计单位
  629. this.xcfzrValue = ''; //重置现场负责人
  630. this.xmfzrValue = ''; //重置项目负责人
  631. this.jsdwValue = ''; //重置建设单位
  632. this.enginId = ''; //重置工程id
  633. this.fileArr = ''
  634. this.createTime = '';
  635. this.infonId = '';
  636. },
  637. changeSelect(item, index) {
  638. // this.index = index;
  639. // this.address = item.communityName;
  640. this.open = false;
  641. if (this.type == 'cz') {
  642. this.materialValue = item;
  643. this.specificationValue = ''; //重置规格
  644. //根据材质ID 获取规格数据
  645. getEnginSpecificationsList(item.id).then(res => {
  646. this.materialList = res.data
  647. this.czggslList[this.SelectIndex].cz.id = this.materialValue.id
  648. this.czggslList[this.SelectIndex].cz.name = this.materialValue.name
  649. })
  650. } else if (this.type == 'gg') {
  651. this.specificationValue = item;
  652. this.czggslList[this.SelectIndex].gg.id = this.specificationValue.id
  653. this.czggslList[this.SelectIndex].gg.name = this.specificationValue.name
  654. } else if (this.type == 'gcmc') {
  655. this.projectName = item
  656. //根据工程id 获取工程信息
  657. getEngineeringDetails(item.id).then(response => {
  658. console.log("res", response)
  659. // this.enginList = response.data
  660. this.jlPhoneValue = response.data.supervisionPhone; //监理电话
  661. this.jlfzrValue = response.data.supervisionHead; //监理负责人
  662. this.jldwValue = response.data.supervisionUnit; //监理单位
  663. this.sjPhoneValue = response.data.designPhone; //设计电话
  664. this.sjfzrValue = response.data.designHead; //设计负责人
  665. this.sjdwValue = response.data.designUnit; //设计单位
  666. this.xcfzrValue = response.data.sceneHead; //现场负责人
  667. this.xmfzrValue = response.data.projectHead; //项目负责人
  668. this.jsdwValue = response.data.constructUnit; //建设单位
  669. this.enginId = response.data.id; //工程id
  670. this.fileArr = response.data.pics
  671. this.createTime = response.data.createTime;
  672. this.infonId = response.data.zEngineeringNodeBoList[0].zEngineeringInfoBoList[0].id
  673. });
  674. }
  675. },
  676. //关闭弹窗
  677. close(e) {
  678. this.open = false
  679. },
  680. //关闭弹窗
  681. closeDict(e) {
  682. this.openDict = false
  683. },
  684. chooseModel(url, name) {
  685. this.cancelText = '复制';
  686. this.confirmText = "下载";
  687. this.titleText = "温馨提示"
  688. this.popupText = "下载或者复制链接";
  689. this.show_loding = true;
  690. this.fileName = name;
  691. this.fileUrl = url; //文件名称和下载地址赋值
  692. },
  693. //取消按钮
  694. cancel_loding() {
  695. let _this = this;
  696. _this.show_loding = false;
  697. console.log("复制")
  698. if (!_this.isEmpty(_this.fileUrl)) {
  699. console.log(_this.fileUrl)
  700. console.log(_this.fileName)
  701. uni.setClipboardData({
  702. data: _this.fileUrl,
  703. success() {
  704. uni.showToast({
  705. title: '已复制' + _this.fileName + '地址成功 请在浏览器打开',
  706. icon: 'none'
  707. });
  708. },
  709. fail(e) {
  710. console.log("失败", e)
  711. uni.showToast({
  712. title: '复制失败',
  713. icon: 'none'
  714. });
  715. }
  716. });
  717. }
  718. },
  719. //确定按钮
  720. confirm_loding() {
  721. this.show_loding = false;
  722. console.log("下载")
  723. this.download(this.fileUrl, this.fileName);
  724. },
  725. getDownLoadFilePath() {
  726. let cachePath = `${uni.env.USER_DATA_PATH}/downloads`
  727. let fm = uni.getFileSystemManager()
  728. try {
  729. // 访问成功则存在
  730. fm.accessSync(cachePath)
  731. } catch (error) {
  732. // 不存在则新建
  733. fm.mkdirSync(cachePath, true)
  734. }
  735. return cachePath
  736. },
  737. download(url, name) {
  738. let savePath = this.getDownLoadFilePath();
  739. console.log('点击下载', url);
  740. console.log('点击下载333', savePath);
  741. //var savePath = uni.env.USER_DATA_PATH + '/savePath'
  742. uni.downloadFile({
  743. url: url,
  744. success: response => {
  745. if (response.statusCode === 200) {
  746. console.log("数据", response)
  747. uni.getFileSystemManager().saveFile({
  748. tempFilePath: response.tempFilePath,
  749. filePath: `${savePath}/${name}`,
  750. success: (resData) => {
  751. console.log('保存路径', resData.savedFilePath)
  752. console.log("dd", resData)
  753. uni.showToast({
  754. title: '下载成功' + resData.savedFilePath
  755. })
  756. },
  757. fail: error => {
  758. console.log('error: ', error)
  759. }
  760. })
  761. }
  762. }
  763. })
  764. },
  765. //历史
  766. history() {
  767. if (this.isEmpty(this.projectType.dictValue)) {
  768. this.$modal.msg('请选择工程类型')
  769. return
  770. }
  771. if (this.isEmpty(this.projectName.id)) {
  772. this.$modal.msg('请选择工程名称')
  773. return
  774. }
  775. getEngineeringHistoryList(this.enginId, this.objValue.value).then(response => {
  776. console.log("历史", response)
  777. this.historyList = response.data
  778. if (response.data.zEngineeringNodeBo != null) {
  779. this.$refs.refShare.handleShowShare();
  780. } else {
  781. this.$modal.msg("暂无历史信息")
  782. }
  783. });
  784. },
  785. submit() {
  786. console.log("文件", this.fileArr)
  787. if (this.isEmpty(this.projectType.dictValue)) {
  788. this.$modal.msg('请选择工程类型')
  789. return
  790. }
  791. if (this.isEmpty(this.projectName.id)) {
  792. this.$modal.msg('请选择工程名称')
  793. return
  794. }
  795. // if (this.isEmpty(this.jsdwValue)) {
  796. // this.$modal.msg('建设单位不能为空')
  797. // return
  798. // }
  799. // if (this.isEmpty(this.xmfzrValue)) {
  800. // this.$modal.msg('项目负责人不能为空')
  801. // return
  802. // }
  803. // if (this.isEmpty(this.xcfzrValue)) {
  804. // this.$modal.msg('现场负责人不能为空')
  805. // return
  806. // }
  807. // if (this.isEmpty(this.sjdwValue)) {
  808. // this.$modal.msg('设计单位不能为空')
  809. // return
  810. // }
  811. // if (this.isEmpty(this.sjfzrValue)) {
  812. // this.$modal.msg('设计负责人不能为空')
  813. // return
  814. // }
  815. // if (this.isEmpty(this.sjPhoneValue)) {
  816. // this.$modal.msg('设计联系电话不能为空')
  817. // return
  818. // }
  819. // if (!this.$validation.mobile(this.sjPhoneValue)) {
  820. // this.$modal.msg('设计联系电话格式错误')
  821. // return
  822. // }
  823. // if (this.isEmpty(this.jldwValue)) {
  824. // this.$modal.msg('监理单位不能为空')
  825. // return
  826. // }
  827. // if (this.isEmpty(this.jlfzrValue)) {
  828. // this.$modal.msg('监理负责人不能为空')
  829. // return
  830. // }
  831. // if (this.isEmpty(this.jlPhoneValue)) {
  832. // this.$modal.msg('监理联系电话不能为空')
  833. // return
  834. // }
  835. // if (!this.$validation.mobile(this.jlPhoneValue)) {
  836. // this.$modal.msg('监理联系电话格式错误')
  837. // return
  838. // }
  839. // if (this.fileArr.length <= 0) {
  840. // this.$modal.msg('请上传文件')
  841. // } else if (this.loadingFile == false) {
  842. // this.$modal.msg('文件未上传完毕,无法提交!')
  843. // }
  844. try {
  845. //console.log("刚开始", this.czggslList);
  846. this.czggslList.forEach((list) => {
  847. if (this.isEmpty(list.cz.id)) {
  848. this.$modal.msg('材质不能为空')
  849. throw new Error('End Loop')
  850. }
  851. if (this.isEmpty(list.gg.id)) {
  852. this.$modal.msg('规格不能为空')
  853. throw new Error('End Loop')
  854. }
  855. if (this.isEmpty(list.sl)) {
  856. this.$modal.msg('数量不能为空')
  857. throw new Error('End Loop')
  858. }
  859. })
  860. } catch (e) {
  861. if (e.message === 'End Loop') throw e
  862. }
  863. if (this.imgArr.length <= 0) {
  864. this.$modal.msg('请上传照片或视频')
  865. return
  866. }
  867. if (this.loading == false) {
  868. this.$modal.msg('照片或视频未上传完毕,无法提交!')
  869. return
  870. }
  871. this.zEngineeringMaterialBo = [];
  872. this.czggslList.forEach((list) => {
  873. this.zEngineeringMaterialBo.push({
  874. materialQuality: list.cz.id,
  875. specifications: list.gg.id,
  876. number: list.sl
  877. })
  878. }),
  879. console.log("数据", this.zEngineeringMaterialBo)
  880. let param = {
  881. files: this.fileArr, //文件
  882. id: this.enginId, //工程id
  883. type: '1', // 用来区分工业工程=1、市政工程=2
  884. enginName: this.projectName.name, //工程名称
  885. enginType: this.projectType.dictValue, // 工程类型
  886. constructUnit: this.jsdwValue, // 建筑单位
  887. projectHead: this.xmfzrValue, // 项目负责人
  888. sceneHead: this.xcfzrValue, // 现场负责人
  889. designUnit: this.sjdwValue, // 设计单位
  890. designHead: this.sjfzrValue, // 设计负责人
  891. designPhone: this.sjPhoneValue, // 设计联系电话
  892. supervisionUnit: this.jldwValue, // 监理单位
  893. supervisionHead: this.jlfzrValue, // 监理负责人
  894. supervisionPhone: this.jlPhoneValue, // 监理联系电话
  895. enginClassification: this.objValue.value, // 工程分类 上一页面传过来的
  896. zEngineeringNodeBo: {
  897. createTime: this.createTime,
  898. type: '工业工程', // 写死
  899. zEngineeringInfoBo: {
  900. engInfoId: this.infonId,
  901. constructTime: this.time, //施工时间
  902. zEngiineeringPhotoBoList: this.imgArr, //照片集合
  903. zEngineeringMaterialBo: this.zEngineeringMaterialBo // 用料对象
  904. }
  905. }
  906. }
  907. Submitengineering(param).then(res => {
  908. if (res.code == '200') {
  909. uni.showToast({
  910. title: res.msg,
  911. icon: 'none',
  912. //显示持续时间为 3秒
  913. duration: 2000
  914. });
  915. setTimeout(function() {
  916. uni.navigateBack();
  917. }, 1000)
  918. }
  919. })
  920. }
  921. }
  922. }
  923. </script>
  924. <style>
  925. .container {
  926. display: flex;
  927. margin-left: 10px;
  928. margin-top: 10px;
  929. margin-right: 10px;
  930. align-items: flex-start;
  931. justify-content: space-between;
  932. }
  933. .text {
  934. font-size: 16px;
  935. color: #333;
  936. }
  937. .background {
  938. border: 15px solid hsla(0, 0%, 100%, .5);
  939. background: white;
  940. background-clip: padding-box;
  941. /*从padding开始往外面裁剪背景*/
  942. }
  943. .btn {
  944. margin-top: 40px;
  945. margin-right: 20px;
  946. margin-bottom: 120px;
  947. margin-left: 20px;
  948. height: 45px;
  949. }
  950. .number {
  951. display: flex;
  952. /* 水平居中显示子元素 */
  953. align-items: flex-start;
  954. /* 垂直居中显示子元素 */
  955. justify-content: space-between;
  956. /* 左右间距等于间距大小 */
  957. padding: 10px;
  958. /* 设置padding以提高视觉效果 */
  959. }
  960. .textarea {
  961. margin-top: 10upx;
  962. width: 100%;
  963. border: 1rpx solid red;
  964. min-height: 100upx;
  965. line-height: 20px;
  966. }
  967. page {
  968. background: #f2f2f2;
  969. }
  970. .flex-x {
  971. display: flex;
  972. align-items: center;
  973. }
  974. .template_title,
  975. .template_title1,
  976. .template_title_list {
  977. height: 90rpx;
  978. background: #fff;
  979. justify-content: space-between;
  980. padding: 0 30rpx;
  981. box-sizing: border-box;
  982. }
  983. .template_title1 {
  984. background: none;
  985. }
  986. .template_title_list {
  987. margin-bottom: 4rpx;
  988. }
  989. .template_title>view,
  990. .template_title1>view {
  991. font-size: 32rpx;
  992. color: #8f8f8f;
  993. flex-shrink: 0;
  994. margin-right: 20rpx;
  995. }
  996. .template_title>input {
  997. font-size: 28rpx;
  998. color: #808080;
  999. text-align: right;
  1000. flex-grow: 1;
  1001. }
  1002. /* 添加内容 */
  1003. .add_con>text {
  1004. font-size: 40rpx;
  1005. color: #f16765;
  1006. display: block;
  1007. margin-right: 20rpx;
  1008. margin-left: 10rpx;
  1009. line-height: 44rpx;
  1010. }
  1011. .add_con>view {
  1012. font-size: 32rpx;
  1013. color: #7885cb;
  1014. }
  1015. /* 删除内容 */
  1016. .del {
  1017. font-size: 32rpx;
  1018. color: #f16765;
  1019. margin-right: 14rpx;
  1020. padding: 20rpx;
  1021. }
  1022. input {
  1023. flex-grow: 1;
  1024. font-size: 28rpx;
  1025. color: #808080;
  1026. }
  1027. .btn {
  1028. margin-top: 100rpx;
  1029. }
  1030. </style>