enginproject.vue 30 KB

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