municipal.vue 32 KB

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