update.vue 18 KB

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