enginproject.vue 27 KB

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