update.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  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 class="margin-top-ssm cu-btn round line-blue text-white">
  16. <button class="cu-btn line-blue" style="padding:0 20rpx 0 10rpx" @click="save(1)">
  17. <text class="text-white">预览</text>
  18. </button>
  19. <template v-if="!(dateList[0].taskStatus == '0' || dateList[0].taskStatus == '1')">
  20. <text class="bg-white" style="width: 1rpx;height: 30rpx;"></text>
  21. <button class=" cu-btn line-blue" style="padding:0 10rpx 0 20rpx" @click="save()">
  22. <text class="text-white">保存</text>
  23. </button>
  24. </template>
  25. </button>
  26. </view>
  27. </block>
  28. </cu-custom>
  29. <view v-for="(data,index) in dateList" :key="index">
  30. <form>
  31. <view class="cu-form-group_1 flex justify-between">
  32. <view>
  33. <text class="title">日志{{index+1}}</text>
  34. <button class="cu-btn round sm margin-left-sm" @click="addNow(index)" v-if="!(data.taskStatus==0 || data.taskStatus==1)">复制当前</button>
  35. </view>
  36. <button class="cu-btn round sm" @click="delOne(index)" v-if="!(data.taskStatus==0 || data.taskStatus==1)&&(index != 0)">删除</button>
  37. </view>
  38. <template v-if="project && project.contract_type == 1">
  39. <checkbox-group @change="checkboxChange($event,index,1)" class="block" style="padding: 0 10px;background-color: #FFFFFF;">
  40. <view>单位</view>
  41. <template v-for="(item,index2) in constructi2onList">
  42. <view style="padding-top: 10px;">
  43. <checkbox v-if="item.contractorUnitName" :value='item.id' class='round' :class="item.checked?'checked':''" :checked="item.checked" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" style="transform:scale(0.82)"></checkbox>
  44. <text style="margin-left: 20rpx;">{{item.contractorUnitName}}</text>
  45. </view>
  46. </template>
  47. </checkbox-group>
  48. <checkbox-group @change="checkboxChange($event,index,2)" class="block" style="padding: 0 10px;background-color: #FFFFFF;">
  49. <view>合同段</view>
  50. <template v-for="(item,index2) in contractIdDataList">
  51. <span style="padding-top: 10px;margin-right: 30rpx;">
  52. <checkbox v-if="item.contractNumber" :value='item.id' class='round' :class="item.checked?'checked':''" :checked="item.checked" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" style="transform:scale(0.82)"></checkbox>
  53. <text style="margin-left: 10rpx;">{{item.contractNumber}}</text>
  54. </span>
  55. </template>
  56. </checkbox-group>
  57. </template>
  58. <view class="cu-form-group_1">
  59. <view class="title">日期</view>
  60. <input placeholder-style="color:#AEAEAE" placeholder="请输入" disabled="" v-model="data.date" name="input"></input>
  61. </view>
  62. <view class="cu-form-group_1">
  63. <view class="title">天气</view>
  64. <input placeholder-style="color:#AEAEAE" placeholder="请输入" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" v-model="data.weather" name="input"></input>
  65. </view>
  66. <view class="cu-form-group_1">
  67. <view class="title">编号</view>
  68. <input placeholder-style="color:#AEAEAE" placeholder="请输入" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" v-model="data.serialNumber" name="input"></input>
  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.securityUserName" name="input"></input>
  73. </view>
  74. </form>
  75. <form>
  76. <view class="cu-form-group_2">
  77. <view class="title">施工"三类人员"到岗情况</view>
  78. <view>
  79. <textarea placeholder-style="color:#AEAEAE" maxlength="-1" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" v-model="data.sanleirenyuan" placeholder="请输入"></textarea>
  80. </view>
  81. </view>
  82. <view class="cu-form-group_2">
  83. <view class="title">施工现场安全状况</view>
  84. <view>
  85. <textarea placeholder-style="color:#AEAEAE" maxlength="-1" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" v-model="data.accidentContent" placeholder="请输入"></textarea>
  86. </view>
  87. </view>
  88. <view class="cu-form-group_2">
  89. <view class="title">危险性较大工程施工安全措施落实情况</view>
  90. <view>
  91. <textarea placeholder-style="color:#AEAEAE" maxlength="-1" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" v-model="data.acceptance" placeholder="请输入"></textarea>
  92. </view>
  93. </view>
  94. <view class="cu-form-group_2">
  95. <view class="title">施工临时用电安全措施落实情况</view>
  96. <view>
  97. <textarea placeholder-style="color:#AEAEAE" maxlength="-1" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" v-model="data.problem" placeholder="请输入"></textarea>
  98. </view>
  99. </view>
  100. <view class="cu-form-group_2">
  101. <view class="title">重大安全隐患、危险源安全监控措施落实情况</view>
  102. <view>
  103. <textarea placeholder-style="color:#AEAEAE" maxlength="-1" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" v-model="data.problemRectify" placeholder="请输入"></textarea>
  104. </view>
  105. </view>
  106. <view class="cu-form-group_2">
  107. <view class="title">存在的安全隐患及处理措施</view>
  108. <view>
  109. <textarea placeholder-style="color:#AEAEAE" maxlength="-1" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" v-model="data.danger" placeholder="请输入"></textarea>
  110. </view>
  111. </view>
  112. <view class="cu-form-group_2">
  113. <view class="title">其他有关事项记录</view>
  114. <view>
  115. <textarea placeholder-style="color:#AEAEAE" maxlength="-1" :disabled="(data.taskStatus==0)||(data.taskStatus==1)" v-model="data.dangerRectify" placeholder="请输入"></textarea>
  116. </view>
  117. </view>
  118. </form>
  119. </view>
  120. <view class="cu-bar bg-white tabbar" style="border: none;"></view>
  121. <view class="cu-bar bg-white tabbar border shop" style="position: fixed;bottom: 0;left: 0;width: 100%;border-top: 1rpx solid #EAEAEA;">
  122. <view class="flex solid-bottom padding justify-between" style="width: 100%;">
  123. <text></text>
  124. <button class="cu-btn round" @click="addOne" v-if="!(dateList[0].taskStatus == '0' || dateList[0].taskStatus == '1')">新增</button>
  125. </view>
  126. </view>
  127. </view>
  128. </template>
  129. <script>
  130. export default {
  131. data() {
  132. return {
  133. dotStyle: {
  134. color: 'black'
  135. },
  136. project: "",
  137. time: "",
  138. constructionList: [],
  139. supervisionList: [],
  140. modalShow: false,
  141. // data: {
  142. // },
  143. dateList:[{
  144. pageNumber:1,
  145. recorderId:uni.getStorageSync("userInfo").id,
  146. contractId:uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id).contractId,
  147. }],
  148. updateOrInsert: 0, //0为新增 , 1为编辑
  149. upId: null,
  150. constructi2onList:[],
  151. contractIdDataList:[],
  152. contractId : uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id).contractId,
  153. project:uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id),
  154. recorderId:uni.getStorageSync("userInfo").id,
  155. }
  156. },
  157. async onLoad(e) {
  158. this.dateList[0].date = e.time;
  159. this.project = uni.getStorageSync("porject" + "_" + uni.getStorageSync("userInfo").id);
  160. this.updateOrInsert = e.type;
  161. this.upId = e.id;
  162. if(this.project.contract_type == 1){
  163. await this.getcontractInfoListByContract();
  164. }
  165. //console.log(this.constructi2onList)
  166. //debugger
  167. if (this.updateOrInsert == 1) { //获取日志信息进行绑定
  168. //this.findData(this.upId);
  169. this.getDataByDate(e.time);
  170. } else {
  171. //获取合同段的地址,根据地址获取温度和天气
  172. var that = this;
  173. var cityName = uni.getStorageSync("porject" + "_" + uni.getStorageSync("userInfo").id).project_place;
  174. that.http.request("/app/diary/getWeather", {
  175. projectId:that.project.id,
  176. contractId:that.contractId,
  177. date:e.time
  178. }).then((res) => {
  179. //that.$set(that.data,'averageTemperature',res.tempSection);
  180. that.$set(that.dateList[0], 'weather', res.weather);
  181. //that.data.averageTemperature =res.tempSection;
  182. //that.data.weather = res.weather
  183. })
  184. //获取上一个审核人
  185. this.getReviewer(e.time);
  186. }
  187. uni.$on('report',this.reportSuccess)
  188. },
  189. onUnload(){
  190. uni.$off('report',this.reportSuccess)
  191. },
  192. methods: {
  193. showdialog() {
  194. this.modalShow = !this.modalShow;
  195. },
  196. datechange(e) {
  197. this.data.startTime = e.fullDate
  198. this.showdialog();
  199. },
  200. navTo(value) {
  201. uni.navigateTo({
  202. url: "/pages/constructionLog/personnel/personnel?type=" + value
  203. })
  204. },
  205. //获取该日志的数据,编辑
  206. findData(id) {
  207. var that = this;
  208. that.http.request('/app/supersecurity/getDataById', {
  209. id: id
  210. }).then((result) => {
  211. that.data = result.data;
  212. that.$delete(that.data, 'prefix');
  213. })
  214. },
  215. save(type) {
  216. if(!this.verification()){
  217. uni.showToast({
  218. title: '至少需要填写一项内容',
  219. icon:'none',
  220. duration: 2000
  221. });
  222. return;
  223. }
  224. // this.data.contractId = this.project.contractId;
  225. // this.data.recorderId = uni.getStorageSync("userInfo").id;
  226. for (let j = 0; j < this.dateList.length; j++) {
  227. if (this.constructi2onList && this.constructi2onList.length > 0) {
  228. var arr = [];
  229. for (var i = 0; i < this.constructi2onList.length; i++) {
  230. if(this.constructi2onList[i].checked){
  231. arr.push(this.constructi2onList[i].id)
  232. }
  233. }
  234. this.dateList[j].constructionUnits = arr.join(',');
  235. } else {
  236. this.dateList[j].constructionUnits = null;
  237. }
  238. if (this.contractIdDataList && this.contractIdDataList.length > 0) {
  239. var arr = [];
  240. for (var i = 0; i < this.contractIdDataList.length; i++) {
  241. if(this.contractIdDataList[i].checked){
  242. arr.push(this.contractIdDataList[i].id)
  243. }
  244. }
  245. this.dateList[j].contractIds = arr.join(',');
  246. } else {
  247. this.dateList[j].contractIds = null;
  248. }
  249. }
  250. //this.http.request('/app/supersecurity/addEntity.json', JSON.stringify(this.dateList), 1).then((res) => {
  251. this.http.request('/app/supersecurity/addEntity.json', {voStr:JSON.stringify(this.dateList),storeName:uni.getStorageSync("storeName")}).then((res) => {
  252. if (res.result == "1") {
  253. //this.data.id = res.data.id;
  254. let urlArr = [];
  255. for (let i = 0; i < res.datas.length; i++) {
  256. this.dateList[i].id = res.datas[i].id;
  257. this.dateList[i].outUrl = res.datas[i].outUrl;
  258. urlArr.push(res.datas[i].outUrl);
  259. }
  260. this.$prompt.none(res.msg);
  261. setTimeout(()=> {
  262. if (type == 1) {
  263. //跳去预览
  264. uni.navigateTo({
  265. url: "/pages/view/preview/preview?previews=" + urlArr.join(',')
  266. })
  267. }else if(type == 2){
  268. getApp().globalData.diary = res.datas[0];
  269. uni.navigateTo({
  270. url:"/pages/dataReport/dailyReport?urlName="+"supersecurity"+"&isZJ="+"0"
  271. })
  272. } else {
  273. uni.navigateBack({
  274. delta: 1
  275. })
  276. }
  277. }, 500)
  278. } else {
  279. this.$prompt.Error("保存失败,"+res.msg);
  280. }
  281. })
  282. },
  283. radioChange(event,type){
  284. //console.log(event.target.value,type);
  285. this.data[type] = event.target.value;
  286. },
  287. verification(){
  288. let verify = true;
  289. for (let i = 0; i < this.dateList.length; i++) {
  290. if(!this.dateList[i].serialNumber && !this.dateList[i].sanleirenyuan &&
  291. !this.dateList[i].buildContent && !this.dateList[i].accidentContent &&
  292. !this.dateList[i].acceptance && !this.dateList[i].problem &&
  293. !this.dateList[i].problemRectify && !this.dateList[i].danger &&
  294. !this.dateList[i].dangerRectify
  295. ){
  296. verify = false;
  297. }else{
  298. verify = true;
  299. }
  300. }
  301. return verify;
  302. },
  303. addOne(){
  304. this.dateList.push({
  305. date:this.dateList[0].date,//日期
  306. weather:this.dateList[0].weather,//天气
  307. pageNumber:this.dateList[this.dateList.length-1].pageNumber+1,
  308. recorderId:this.dateList[0].recorderId,
  309. contractId:this.dateList[0].contractId
  310. })
  311. },
  312. addNow(index){
  313. let addObj = Object.assign({},this.dateList[index]);
  314. addObj.pageNumber = addObj.pageNumber+1;
  315. addObj.id = '';
  316. for (let i = index+1; i < this.dateList.length; i++) {
  317. this.dateList[i].pageNumber += 1;
  318. }
  319. this.dateList.splice(index+1,0,addObj);
  320. //console.log(this.dateList)
  321. },
  322. delOne(index){
  323. uni.showModal({
  324. title: '删除',
  325. content: '是否删除 日志'+(index+1)+' ?'+'删除后无法还原',
  326. success:(res) => {
  327. if (res.confirm) {
  328. //console.log('用户点击确定');
  329. //没保存过直接删
  330. if(!this.dateList[index].id){
  331. this.dateList.splice(index,1);
  332. return;
  333. }
  334. //保存过的需要请求
  335. this.http.request('/app/supersecurity/del', {
  336. id: this.dateList[index].id,
  337. }).then((result) => {
  338. if(result.result ==1){
  339. this.dateList.splice(index,1);
  340. }else{
  341. this.$prompt.Error("删除失败");
  342. }
  343. })
  344. } else if (res.cancel) {
  345. //console.log('用户点击取消');
  346. }
  347. }
  348. });
  349. },
  350. getDataByDate(date){
  351. this.http.request('/app/supersecurity/getDataByDate', {
  352. date: date,
  353. recorderId:this.recorderId,
  354. contractId:this.contractId,
  355. }).then((result) => {
  356. if(result.result ==1){
  357. for (let i = 0; i < result.datas.length; i++) {
  358. result.datas[i].contractId = this.contractId;
  359. }
  360. this.dateList =result.datas;
  361. var items,values;
  362. if(this.dateList[0].constructionUnits){
  363. items= this.constructi2onList;
  364. values = this.dateList[0].constructionUnits.split(",");
  365. this.setChecked(items,values)
  366. }
  367. if(this.dateList[0].contractIds){
  368. values = this.dateList[0].contractIds.split(",");
  369. items= this.contractIdDataList;
  370. this.setChecked(items,values)
  371. }
  372. }else{
  373. }
  374. })
  375. },
  376. getPageNumber(){
  377. let max = 1;
  378. for (let i = 0; i < this.dateList.length; i++) {
  379. if(this.dateList[i].pageNumber > max){
  380. max = this.dateList[i].pageNumber;
  381. }
  382. }
  383. return max+1;
  384. },
  385. getReviewer(date){
  386. //获取上一个审核人
  387. this.http.request("/app/supersecurity/getReviewer", {
  388. projectId:this.project.id,
  389. contractId:this.contractId,
  390. date:date
  391. }).then((res) => {
  392. if(res.data && this.dateList[0]){
  393. this.$set(this.dateList[0], 'securityUserName', res.data);
  394. }
  395. })
  396. },
  397. async getcontractInfoListByContract(){
  398. let result = await this.http.request('/app/parameterLog/getcontractInfoListByContract',{
  399. contractId:this.contractId,
  400. })
  401. if(result.result == '1'){
  402. this.constructi2onList = [];
  403. this.contractIdDataList = [];
  404. for (var i = 0; i < result.datas.length; i++) {
  405. this.constructi2onList.push({
  406. id:result.datas[i].id,
  407. contractorUnitName:result.datas[i].contractorUnitName,
  408. checked:false,
  409. })
  410. this.contractIdDataList.push({
  411. id:result.datas[i].id,
  412. contractNumber:result.datas[i].contractNumber,
  413. checked:false,
  414. })
  415. }
  416. }else{
  417. }
  418. },
  419. checkboxChange(e,index,type){
  420. //console.log(e.detail.value)
  421. let items = []
  422. if(type == 1){
  423. items = this.constructi2onList
  424. }else if(type == 2){
  425. items = this.contractIdDataList
  426. }
  427. let values = e.detail.value
  428. this.setChecked(items,values)
  429. },
  430. setChecked(items,values){
  431. for (let i = 0, lenI = items.length; i < lenI; ++i) {
  432. items[i].checked = false
  433. for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
  434. if (items[i].id === values[j]) {
  435. //console.log(values[j])
  436. items[i].checked = true
  437. break
  438. }
  439. }
  440. }
  441. },
  442. repeal(){
  443. let { account } = uni.getStorageSync('userInfo')
  444. uni.showModal({
  445. title: '废除',
  446. content: '是否废除任务?',
  447. success:(res) => {
  448. if (res.confirm) {
  449. this.http.request('/app/task/repeal', {
  450. taskId: this.dateList[0].taskId,
  451. opUserName: account ? account : '',
  452. }).then((result) => {
  453. if(result.result ==1){
  454. this.$prompt.none("废除成功");
  455. this.getDataByDate(this.dateList[0].date);
  456. }else{
  457. this.$prompt.Error("废除失败");
  458. }
  459. })
  460. } else if (res.cancel) {
  461. //console.log('用户点击取消');
  462. }
  463. }
  464. });
  465. },
  466. reportSuccess(){
  467. //上报成功,刷新
  468. this.getDataByDate(this.dateList[0].date);
  469. }
  470. },
  471. onShow() {
  472. },
  473. }
  474. </script>
  475. <style>
  476. .solid-top-type {
  477. border-top: 0px solid #eee;
  478. }
  479. .cu-form-group_1 {
  480. display: flex;
  481. align-items: center;
  482. padding: 0 22rpx;
  483. background-color: #fff;
  484. border-bottom: 2rpx solid #EAEAEA;
  485. height: 88rpx;
  486. }
  487. .cu-form-group_1 .title {
  488. font-size: 30rpx;
  489. color: #101010;
  490. width: 154rpx;
  491. }
  492. .cu-form-group_1 input {
  493. font-size: 30rpx;
  494. color: #8a8a8a;
  495. }
  496. .cu-form-group_2 {
  497. padding: 22rpx;
  498. background-color: #fff;
  499. border-bottom: 2rpx solid #EAEAEA;
  500. }
  501. .cu-form-group_2 .title {
  502. font-size: 30rpx;
  503. color: #101010;
  504. padding-bottom: 18rpx;
  505. }
  506. .cu-form-group_2 textarea {
  507. font-size: 30rpx;
  508. color: #8a8a8a;
  509. width: 100%;
  510. }
  511. .cu-modal.show {
  512. overflow-y: auto;
  513. pointer-events: auto;
  514. }
  515. </style>