update.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. <template>
  2. <view>
  3. <!-- 顶部 -->
  4. <cu-custom bgColor="bg-blue" :isBack="true">
  5. <block slot="backText">编辑监理日志</block>
  6. <block slot="content"></block>
  7. <block slot="right">
  8. <view class=" flex justify-center">
  9. <template v-if="dateList[0].taskStatus == '0' || dateList[0].taskStatus == '1'">
  10. <button @click="repeal()" class="margin-top-ssm cu-btn line-blue round text-white" style="width: 130rpx;height: 66rpx;padding: 0;">废除</button>
  11. </template>
  12. <template v-else>
  13. <button @click="save(2)" class="margin-top-ssm cu-btn line-blue round text-white" style="width: 130rpx;height: 66rpx;padding: 0;">上报</button>
  14. </template>
  15. <!-- <button @click="save()" class="margin-top-ssm cu-btn line-blue round text-white" style="width: 160rpx;height: 66rpx;padding: 0;">保存</button> -->
  16. <button class="margin-top-ssm cu-btn round line-blue text-white">
  17. <button class="cu-btn line-blue" style="padding:0 20rpx 0 10rpx" @click="save(1)">
  18. <text class="text-white">预览</text>
  19. </button>
  20. <template v-if="!(dateList[0].taskStatus == '0' || dateList[0].taskStatus == '1')">
  21. <text class="bg-white" style="width: 1rpx;height: 30rpx;"></text>
  22. <button class=" cu-btn line-blue" style="padding:0 10rpx 0 20rpx" @click="save()">
  23. <text class="text-white">保存</text>
  24. </button>
  25. </template>
  26. </button>
  27. </view>
  28. </block>
  29. </cu-custom>
  30. <!-- 项目合同段信息 -->
  31. <!-- <view style="background-color: #fff;padding: 22rpx;margin-bottom: 20rpx;">
  32. <view style="font-size: 30rpx;color: #101010;font-weight: bold;">{{project.project_name}}</view>
  33. <view style="font-size: 28rpx;color: #101010;margin-top: 10rpx;">{{project.contractName}}</view>
  34. </view> -->
  35. <view v-for="(data,index) in dateList" :key="index">
  36. <form>
  37. <view class="cu-form-group_1 flex justify-between">
  38. <view>
  39. <text class="title">日志{{index+1}}</text>
  40. <button class="cu-btn round sm margin-left-sm" v-if="!(data.taskStatus==0 || data.taskStatus==1)" @click="addNow(index)">复制当前</button>
  41. </view>
  42. <button class="cu-btn round sm" @click="delOne(index)" v-if="!(data.taskStatus==0 || data.taskStatus==1)&&(index != 0)">删除</button>
  43. </view>
  44. <view class="cu-form-group_1">
  45. <view class="title">日期</view>
  46. <input placeholder-style="color:#AEAEAE" placeholder="请输入" disabled="" v-model="data.date" name="input"></input>
  47. </view>
  48. <view class="cu-form-group_1">
  49. <view class="title">天气</view>
  50. <input placeholder-style="color:#AEAEAE" placeholder="请输入" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" v-model="data.weather" name="input"></input>
  51. </view>
  52. <view class="cu-form-group_1">
  53. <view class="title">编号</view>
  54. <input placeholder-style="color:#AEAEAE" placeholder="请输入" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" v-model="data.serialNumber" name="input"></input>
  55. </view>
  56. <view class="cu-form-group_1">
  57. <view class="title">审核人</view>
  58. <input placeholder-style="color:#AEAEAE" placeholder="请输入" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" v-model="data.reviewer" name="input"></input>
  59. </view>
  60. </form>
  61. <form>
  62. <view class="cu-form-group_2">
  63. <view class="title">主要施工情况</view>
  64. <view>
  65. <textarea placeholder-style="color:#AEAEAE" maxlength="-1" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" v-model="data.jobContent" placeholder="请输入"></textarea>
  66. </view>
  67. </view>
  68. <view class="cu-form-group_2">
  69. <view class="title">监理主要作业</view>
  70. <view>
  71. <textarea placeholder-style="color:#AEAEAE" maxlength="-1" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" v-model="data.buildContent" placeholder="请输入"></textarea>
  72. </view>
  73. </view>
  74. <view class="cu-form-group_2">
  75. <view class="title">问题及处理情况</view>
  76. <view>
  77. <textarea placeholder-style="color:#AEAEAE" maxlength="-1" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" v-model="data.problem" placeholder="请输入"></textarea>
  78. </view>
  79. </view>
  80. </form>
  81. </view>
  82. <view class="cu-bar bg-white tabbar" style="border: none;"></view>
  83. <view class="cu-bar bg-white tabbar border shop" style="position: fixed;bottom: 0;left: 0;width: 100%;border-top: 1rpx solid #EAEAEA;">
  84. <view class="flex solid-bottom padding justify-between" style="width: 100%;">
  85. <text></text>
  86. <button class="cu-btn round" @click="addOne" v-if="!(dateList[0].taskStatus == '0' || dateList[0].taskStatus == '1')">新增</button>
  87. </view>
  88. </view>
  89. <!-- <form>
  90. <view class="cu-form-group_1" @click="navTo(2)" style="justify-content: space-between;">
  91. <view class="title">监理员</view>
  92. <input placeholder-style="color:#AEAEAE" placeholder="请选择" v-model="data.supervisionWorker" disabled="" style="width: 520rpx;"></input>
  93. <text class='cuIcon-right'></text>
  94. </view>
  95. <view class="cu-form-group_1" @click="navTo(1)" style="justify-content: space-between;">
  96. <view class="title">施工员</view>
  97. <input placeholder-style="color:#AEAEAE" placeholder="请选择" v-model="data.constructionWorker" disabled="" style="width: 520rpx;"></input>
  98. <text class='cuIcon-right'></text>
  99. </view>
  100. </form> -->
  101. <!-- 时间弹窗 -->
  102. <view class="cu-modal bottom-modal" :class="modalShow?'show':''">
  103. <view class="cu-dialog" style="background-color: white;border-radius: 20rpx 20rpx 0 0;">
  104. <view class="cu-bar bg-white">
  105. <view class="action text-gray"></view>
  106. <view class="action text-black text-bold" style="color: #101010;">选择时间</view>
  107. <view class="action text-gray" @tap="showdialog()">取消</view>
  108. </view>
  109. <view style="padding-bottom: 10rpx;">
  110. <calendar @selected-change="datechange" :showBack="false" :dotStyle="dotStyle"></calendar>
  111. </view>
  112. </view>
  113. </view>
  114. </view>
  115. </template>
  116. <script>
  117. export default {
  118. data() {
  119. return {
  120. dotStyle: {
  121. color: 'black'
  122. },
  123. project: "",
  124. time: "",
  125. constructionList: [],
  126. supervisionList: [],
  127. modalShow: false,
  128. // data: {
  129. // },
  130. dateList:[{
  131. pageNumber:1,
  132. recorderId:uni.getStorageSync("userInfo").id,
  133. contractId:uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id).contractId,
  134. }],
  135. updateOrInsert: 0, //0为新增 , 1为编辑
  136. upId: null,
  137. contractId : uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id).contractId,
  138. project:uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id),
  139. recorderId:uni.getStorageSync("userInfo").id,
  140. }
  141. },
  142. onLoad(e) {
  143. this.dateList[0].date = e.time;
  144. this.project = uni.getStorageSync("porject" + "_" + uni.getStorageSync("userInfo").id);
  145. this.updateOrInsert = e.type;
  146. this.upId = e.id;
  147. if (this.updateOrInsert == 1) { //获取日志信息进行绑定
  148. //this.findData(this.upId);
  149. this.getDataByDate(e.time);
  150. } else {
  151. //获取合同段的地址,根据地址获取温度和天气
  152. var that = this;
  153. var cityName = uni.getStorageSync("porject" + "_" + uni.getStorageSync("userInfo").id).project_place;
  154. that.http.request("/app/diary/getWeather", {
  155. projectId:that.project.id,
  156. contractId:that.contractId,
  157. date:e.time
  158. }).then((res) => {
  159. //that.$set(that.data,'averageTemperature',res.tempSection);
  160. that.$set(that.dateList[0], 'weather', res.weather);
  161. //that.data.averageTemperature =res.tempSection;
  162. //that.data.weather = res.weather
  163. })
  164. //获取上一个审核人
  165. this.getReviewer(e.time);
  166. uni.$on('report',this.reportSuccess)
  167. }
  168. },
  169. onUnload(){
  170. uni.$off('report',this.reportSuccess)
  171. },
  172. methods: {
  173. showdialog() {
  174. this.modalShow = !this.modalShow;
  175. },
  176. datechange(e) {
  177. this.data.startTime = e.fullDate
  178. this.showdialog();
  179. },
  180. navTo(value) {
  181. uni.navigateTo({
  182. url: "/pages/constructionLog/personnel/personnel?type=" + value
  183. })
  184. },
  185. //获取该日志的数据,编辑
  186. findData(id) {
  187. var that = this;
  188. that.http.request('/app/superEntity/getDataById', {
  189. id: id
  190. }).then((result) => {
  191. that.data = result.data;
  192. that.$delete(that.data, 'prefix');
  193. })
  194. },
  195. // save(){
  196. // var that =this;
  197. // /* let result= that.$formValidate.validate(this.data,this.rules)//表单验证
  198. // if(result.isOk){ */
  199. // let param =that.data;
  200. // param.contractId= this.project.contractId;
  201. // param.creator= uni.getStorageSync("userInfo").id;
  202. // param.state= that.data.state==null ? 0 : that.data.state;
  203. // param.deleted= that.data.deleted==null ? 0 : that.data.deleted;
  204. // param.createTime=new Date();
  205. // that.http.request('/app/diary/addOrUpdate', param).then((result)=>{
  206. // if(result.result=="1"){
  207. // that.$prompt.none(result.msg);
  208. // setTimeout(function(){
  209. // uni.navigateBack({
  210. // delta:1
  211. // })
  212. // },500)
  213. // }else{
  214. // that.$prompt.Error("保存失败");
  215. // }
  216. // })
  217. // /* }else{
  218. // that.$prompt.none(result.errmsg)
  219. // } */
  220. // }
  221. save(type) {
  222. if(!this.verification()){
  223. uni.showToast({
  224. title: '至少需要填写一项内容',
  225. icon:'none',
  226. duration: 2000
  227. });
  228. return;
  229. }
  230. // this.data.contractId = this.project.contractId;
  231. // this.data.recorderId = uni.getStorageSync("userInfo").id;
  232. //this.http.request('/app/superEntity/addEntity.json', JSON.stringify(this.dateList), 1).then((res) => {
  233. this.http.request('/app/superEntity/addEntity.json', {voStr:JSON.stringify(this.dateList),storeName:uni.getStorageSync("storeName")}).then((res) => {
  234. if (res.result == "1") {
  235. //this.data.id = res.data.id;
  236. let urlArr = [];
  237. for (let i = 0; i < res.datas.length; i++) {
  238. this.dateList[i].id = res.datas[i].id;
  239. this.dateList[i].outUrl = res.datas[i].outUrl;
  240. urlArr.push(res.datas[i].outUrl);
  241. }
  242. this.$prompt.none(res.msg);
  243. setTimeout(()=> {
  244. if (type == 1) {
  245. //跳去预览
  246. uni.navigateTo({
  247. url: "/pages/view/preview/preview?previews=" + urlArr.join(',')
  248. })
  249. }else if(type == 2){
  250. getApp().globalData.diary = res.datas[0];
  251. uni.navigateTo({
  252. url:"/pages/dataReport/dailyReport?urlName="+"superEntity"+"&isZJ="+"0"
  253. })
  254. } else {
  255. uni.navigateBack({
  256. delta: 1
  257. })
  258. }
  259. }, 500)
  260. } else {
  261. this.$prompt.Error("保存失败,"+res.msg);
  262. }
  263. })
  264. },
  265. radioChange(event,type){
  266. //console.log(event.target.value,type);
  267. this.data[type] = event.target.value;
  268. },
  269. verification(){
  270. let verify = true;
  271. for (let i = 0; i < this.dateList.length; i++) {
  272. if(!this.dateList[i].serialNumber && !this.dateList[i].reviewer &&
  273. !this.dateList[i].jobContent && !this.dateList[i].buildContent &&
  274. !this.dateList[i].problem
  275. ){
  276. verify = false;
  277. }else{
  278. verify = true;
  279. }
  280. }
  281. return verify;
  282. },
  283. addOne(){
  284. this.dateList.push({
  285. date:this.dateList[0].date,//日期
  286. weather:this.dateList[0].weather,//天气
  287. pageNumber:this.dateList[this.dateList.length-1].pageNumber+1,
  288. recorderId:this.dateList[0].recorderId,
  289. contractId:this.dateList[0].contractId
  290. })
  291. },
  292. addNow(index){
  293. let addObj = Object.assign({},this.dateList[index]);
  294. addObj.pageNumber = addObj.pageNumber+1;
  295. addObj.id = '';
  296. for (let i = index+1; i < this.dateList.length; i++) {
  297. this.dateList[i].pageNumber += 1;
  298. }
  299. this.dateList.splice(index+1,0,addObj);
  300. //console.log(this.dateList)
  301. },
  302. delOne(index){
  303. uni.showModal({
  304. title: '删除',
  305. content: '是否删除 日志'+(index+1)+' ?'+'删除后无法还原',
  306. success:(res) => {
  307. if (res.confirm) {
  308. //console.log('用户点击确定');
  309. //没保存过直接删
  310. if(!this.dateList[index].id){
  311. this.dateList.splice(index,1);
  312. return;
  313. }
  314. //保存过的需要请求
  315. this.http.request('/app/superEntity/del', {
  316. id: this.dateList[index].id,
  317. }).then((result) => {
  318. if(result.result ==1){
  319. this.dateList.splice(index,1);
  320. }else{
  321. this.$prompt.Error("删除失败");
  322. }
  323. })
  324. } else if (res.cancel) {
  325. //console.log('用户点击取消');
  326. }
  327. }
  328. });
  329. },
  330. getDataByDate(date){
  331. this.http.request('/app/superEntity/getDataByDate', {
  332. date: date,
  333. recorderId:this.recorderId,
  334. contractId:this.contractId,
  335. }).then((result) => {
  336. if(result.result ==1){
  337. for (let i = 0; i < result.datas.length; i++) {
  338. result.datas[i].contractId = this.contractId;
  339. }
  340. this.dateList =result.datas;
  341. }else{
  342. }
  343. })
  344. },
  345. getPageNumber(){
  346. let max = 1;
  347. for (let i = 0; i < this.dateList.length; i++) {
  348. if(this.dateList[i].pageNumber > max){
  349. max = this.dateList[i].pageNumber;
  350. }
  351. }
  352. return max+1;
  353. },
  354. getReviewer(date){
  355. //获取上一个审核人
  356. this.http.request("/app/superEntity/getReviewer", {
  357. projectId:this.project.id,
  358. contractId:this.contractId,
  359. date:date
  360. }).then((res) => {
  361. if(res.data && this.dateList[0]){
  362. this.$set(this.dateList[0], 'reviewer', res.data);
  363. }
  364. })
  365. },
  366. repeal(){
  367. let { account } = uni.getStorageSync('userInfo')
  368. uni.showModal({
  369. title: '废除',
  370. content: '是否废除任务?',
  371. success:(res) => {
  372. if (res.confirm) {
  373. this.http.request('/app/task/repeal', {
  374. taskId: this.dateList[0].taskId,
  375. opUserName: account ? account : '',
  376. }).then((result) => {
  377. if(result.result ==1){
  378. this.$prompt.none("废除成功");
  379. this.getDataByDate(this.dateList[0].date);
  380. }else{
  381. this.$prompt.Error("废除失败");
  382. }
  383. })
  384. } else if (res.cancel) {
  385. //console.log('用户点击取消');
  386. }
  387. }
  388. });
  389. },
  390. reportSuccess(){
  391. //上报成功,刷新
  392. this.getDataByDate(this.dateList[0].date);
  393. }
  394. },
  395. onShow() {
  396. /* 监听选择施工人员页面的handleFun方法 */
  397. // uni.$on("handleFun", res => {
  398. // this.data.constructionWorker="";
  399. // this.constructionList=res;
  400. // res.forEach((item)=>{
  401. // this.data.constructionWorker+=item.user_name
  402. // })
  403. // })
  404. /* 监听选择监理人员页面的handleFun方法 */
  405. // uni.$on("handleFunBy", res => {
  406. // this.data.supervisionWorker="";
  407. // this.supervisionList=res;
  408. // res.forEach((item)=>{
  409. // this.data.supervisionWorker+=item.user_name
  410. // })
  411. // })
  412. },
  413. }
  414. </script>
  415. <style>
  416. .solid-top-type {
  417. border-top: 0px solid #eee;
  418. }
  419. .cu-form-group_1 {
  420. display: flex;
  421. align-items: center;
  422. padding: 0 22rpx;
  423. background-color: #fff;
  424. border-bottom: 2rpx solid #EAEAEA;
  425. height: 88rpx;
  426. }
  427. .cu-form-group_1 .title {
  428. font-size: 30rpx;
  429. color: #101010;
  430. width: 154rpx;
  431. }
  432. .cu-form-group_1 input {
  433. font-size: 30rpx;
  434. color: #8a8a8a;
  435. }
  436. .cu-form-group_2 {
  437. padding: 22rpx;
  438. background-color: #fff;
  439. border-bottom: 2rpx solid #EAEAEA;
  440. }
  441. .cu-form-group_2 .title {
  442. font-size: 30rpx;
  443. color: #101010;
  444. padding-bottom: 18rpx;
  445. }
  446. .cu-form-group_2 textarea {
  447. font-size: 30rpx;
  448. color: #8a8a8a;
  449. width: 100%;
  450. }
  451. .cu-modal.show {
  452. overflow-y: auto;
  453. pointer-events: auto;
  454. }
  455. </style>