enginproject.vue 27 KB

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