enginproject.vue 27 KB

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