monitorlog.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <template>
  2. <view style="background-color: #fff;">
  3. <view class="screen" v-if="current==1" @click="opencale">
  4. <u-icon name="calendar" color="#2979ff" size="24"></u-icon>
  5. </view>
  6. <view class="subsection">
  7. <u-subsection :list="list" :current="current" @change="sectionChange"></u-subsection>
  8. </view>
  9. <view class="weatherbox" v-if="current == 0">
  10. <u--form labelPosition="left" :model="weatherdatas" :rules="rules" ref="uForm">
  11. <u-form-item label="温度" prop="temp" ref="item1">
  12. <u--input v-model="weatherdatas.temp" placeholder="请填写温度" border="none"></u--input>
  13. </u-form-item>
  14. <u-form-item label="天气" prop="weather" ref="item1">
  15. <u--input v-model="weatherdatas.weather" placeholder="请填写天气" border="none"></u--input>
  16. </u-form-item>
  17. <u-form-item label="日期" prop="date" ref="item1" @click="caleshow">
  18. <u--input v-model="weatherdatas.date" disabled disabledColor="#ffffff" placeholder="请选择日期"
  19. border="none"></u--input>
  20. <u-icon slot="right" name="arrow-right"></u-icon>
  21. </u-form-item>
  22. <u-form-item label="地址" prop="city" ref="item1">
  23. <u--input v-model="weatherdatas.city" placeholder="请填写地址" border="none"></u--input>
  24. </u-form-item>
  25. <!-- <u-calendar v-model="tiemshow" mode="range" @change="tiemchange"></u-calendar> -->
  26. </u--form>
  27. <view class="title_box">
  28. <view class="">
  29. 监测内容
  30. </view>
  31. <u-icon size="20" name="plus-circle" color="#409eff" @click="add"></u-icon>
  32. </view>
  33. <view class="task_box" v-for="item,index in tasklist" :key="index">
  34. <u-swipe-action>
  35. <u-swipe-action-item :options="options1" @click="delect(index)">
  36. <view class="swipe-action u-border-top u-border-bottom">
  37. <view class="swipe-action__content" @click="examine(item.imglist)">
  38. <view class="swipe-action__content__text">
  39. <view class="task_box_left">
  40. <view class="task_box_left_f">
  41. {{item.name}}
  42. </view>
  43. <view class="task_box_left_t">
  44. {{item.imglist.length}}张图片
  45. </view>
  46. </view>
  47. <view class="task_box_con">
  48. {{item.text}}
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </u-swipe-action-item>
  54. </u-swipe-action>
  55. </view>
  56. <u-button type="primary" text="提交" @click="submit" style="margin-top: 30rpx;" :loading="passload" shape="circle"></u-button>
  57. </view>
  58. <view class="hisbox" v-else>
  59. <view class="hisbox_hint" v-if="hislist.length==0">
  60. 暂无数据
  61. </view>
  62. <view class="hisbox_item" v-for="item,index in hislist" :key="index" @click="todata(item.id)">
  63. <view class="task_box_left">
  64. <view class="task_box_left_f">
  65. {{item.monitor_time}}
  66. </view>
  67. <view class="task_box_left_t">
  68. {{item.weather}}
  69. </view>
  70. </view>
  71. <view class="task_box_con">
  72. {{item.owner_user}}
  73. </view>
  74. </view>
  75. </view>
  76. <!-- <u-calendar :show="caleshow" mode="range" @confirm="confirm"></u-calendar> -->
  77. <uni-calendar :insert="false" ref="calendar" @confirm="confirm" />
  78. <uni-calendar :insert="false" ref="calendars" :range="true" @confirm="confirms" />
  79. <u-loading-page loading-text="加载中..." :loading="loading" font-size="16"></u-loading-page>
  80. </view>
  81. </template>
  82. <script>
  83. export default {
  84. data() {
  85. return {
  86. list: ['填写监测日志', '历史记录'],
  87. current: 0,
  88. weatherdatas: {
  89. temp: "",
  90. weather: "",
  91. date: "",
  92. city: ""
  93. },
  94. options1: [{
  95. text: '删除'
  96. }],
  97. rules: {
  98. 'temp': {
  99. type: 'number',
  100. required: true,
  101. message: '请填写温度(数字)',
  102. trigger: ['blur', 'change']
  103. },
  104. 'weather': {
  105. type: 'string',
  106. required: true,
  107. message: '请填写天气',
  108. trigger: ['blur', 'change']
  109. },
  110. 'date': {
  111. type: 'string',
  112. required: true,
  113. message: '请填写日期',
  114. trigger: ['blur', 'change']
  115. },
  116. 'city': {
  117. type: 'string',
  118. required: true,
  119. message: '请填写地址',
  120. trigger: ['blur', 'change']
  121. },
  122. },
  123. kpsurlL: "",
  124. tasklist: [],
  125. hislist:[],
  126. start_time:"",//开始时间
  127. end_time:"",//结束时间
  128. page:1,
  129. passload:false,
  130. loading:false,
  131. }
  132. },
  133. methods: {
  134. sectionChange(e) {
  135. this.current = e
  136. if (e == 1) {
  137. this.page = 1
  138. this.hislist = []
  139. this.gethis()
  140. }
  141. },
  142. add() {
  143. uni.navigateTo({
  144. url: "./addcont"
  145. })
  146. },
  147. delect(index) {
  148. // console.log(index)
  149. this.tasklist.splice(index, 1)
  150. },
  151. submit() {
  152. this.$refs.uForm.validate().then(res => {
  153. // console.log(this.tasklist)
  154. if (this.tasklist.length == 0) {
  155. uni.$u.toast('请添加监测内容!')
  156. } else {
  157. this.setcont()
  158. }
  159. }).catch(errors => {
  160. uni.$u.toast('请将信息填写完整!')
  161. })
  162. },
  163. confirm(e) {
  164. console.log(e)
  165. // this.caleshow = false
  166. this.weatherdatas.date = e.fulldate
  167. },
  168. async setcont() {
  169. var list = []
  170. for (var i = 0; i < this.tasklist.length; i++) {
  171. var obj = {
  172. title: this.tasklist[i].name, // 监督事项
  173. message: this.tasklist[i].text, // 监督日期
  174. img_list: this.tasklist[i].imglist, // 监督图片
  175. }
  176. list.push(obj)
  177. }
  178. this.passload = true
  179. const res = await this.$myRequest({
  180. url: '/api/api_gateway?method=app.my.app_monitor_log_add',
  181. data: {
  182. weather: this.weatherdatas.weather, // 必填 天气
  183. temperature: this.weatherdatas.temp, // 必填 温度
  184. address: this.weatherdatas.city, // 必填 检测地点
  185. record_list: JSON.stringify(list), // 必填
  186. monitor_time: this.weatherdatas
  187. .date, // 必填 监督日期 2021-01-03
  188. }
  189. })
  190. this.passload = false
  191. if (res) {
  192. uni.$u.toast('提交成功!')
  193. for (var key in this.weatherdatas) {
  194. this.weatherdatas[key] = []
  195. this.tasklist = []
  196. uni.removeStorage({
  197. key: "addobj",
  198. })
  199. }
  200. }
  201. },
  202. examine(item) {
  203. var imgarr = []
  204. for (var i = 0; i < item.length; i++) {
  205. imgarr.push(this.baseUrl + item[i])
  206. }
  207. uni.previewImage({
  208. urls: imgarr,
  209. current: 0
  210. });
  211. },
  212. async gethis() {
  213. this.loading = true
  214. const res = await this.$myRequest({
  215. url: '/api/api_gateway?method=control_center.task.monitor_log_list',
  216. data: {
  217. page: this.page,
  218. start_time:this.start_time,
  219. end_time: this.end_time
  220. }
  221. })
  222. console.log(res.page_list)
  223. for(var i =0;i<res.page_list.length;i++){
  224. this.hislist.push(res.page_list[i])
  225. }
  226. this.loading = false
  227. },
  228. caleshow() {
  229. this.$refs.calendar.open();
  230. },
  231. opencale() {
  232. this.$refs.calendars.open();
  233. },
  234. confirms(e){
  235. console.log(e.range)
  236. this.start_time = e.range.before
  237. this.end_time = e.range.after
  238. this.hislist = []
  239. this.gethis()
  240. },
  241. todata(id){
  242. uni.navigateTo({
  243. url: './monitorlogdata?id='+id,
  244. });
  245. }
  246. },
  247. onLoad() {
  248. },
  249. onShow() {
  250. var that = this
  251. uni.getStorage({
  252. key: "addobj",
  253. success(res) {
  254. console.log(that.tasklist)
  255. that.tasklist.push(JSON.parse(res.data))
  256. }
  257. })
  258. },
  259. onHide() {
  260. uni.removeStorage({
  261. key: "addobj",
  262. })
  263. },
  264. onReachBottom() {
  265. this.page++
  266. this.gethis()
  267. },
  268. onPullDownRefresh(){
  269. this.hislist = []
  270. this.page = 1
  271. this.start_time="",
  272. this.end_time=""
  273. this.gethis()
  274. setTimeout(() => {
  275. uni.stopPullDownRefresh()
  276. }, 1000)
  277. },
  278. }
  279. </script>
  280. <style lang="less" scoped>
  281. page{
  282. background-color: #f7f7f7;
  283. }
  284. .screen {
  285. position: fixed;
  286. top: 20rpx;
  287. right: 20rpx;
  288. z-index: 9999;
  289. }
  290. .subsection{
  291. width: 100%;
  292. position: fixed;
  293. top: 88rpx;
  294. height: 70rpx;
  295. z-index: 9999;
  296. }
  297. /deep/.u-subsection {
  298. background-color: #f7f7f7 !important;
  299. // margin: 20rpx 0;
  300. .u-subsection__bar {
  301. background-color: #fff;
  302. }
  303. }
  304. .weatherbox {
  305. width: 90%;
  306. margin: 0 auto 0;
  307. padding-top: 80rpx;
  308. padding-bottom: 40rpx;
  309. /deep/.u-form-item__body {
  310. border-bottom: 1px solid #F6F6F6;
  311. margin-bottom: 20rpx;
  312. }
  313. .title_box {
  314. width: 100%;
  315. display: flex;
  316. justify-content: space-between;
  317. margin-top: 30rpx;
  318. margin-bottom: 30rpx;
  319. }
  320. .task_box {
  321. /deep/.swipe-action__content__text {
  322. padding: 20rpx 0;
  323. }
  324. /deep/.u-swipe-action-item__right__button__wrapper {
  325. background-color: red !important;
  326. }
  327. .task_box_left {
  328. display: flex;
  329. justify-content: space-between;
  330. margin-bottom: 20rpx;
  331. .task_box_left_f {
  332. font-weight: 700;
  333. }
  334. .task_box_left_t {
  335. color: #999999;
  336. font-size: 24rpx;
  337. }
  338. }
  339. .task_box_con{
  340. text-overflow: -o-ellipsis-lastline;
  341. overflow: hidden;
  342. text-overflow: ellipsis;
  343. display: -webkit-box;
  344. -webkit-line-clamp: 2;
  345. line-clamp: 2;
  346. -webkit-box-orient: vertical;
  347. }
  348. }
  349. }
  350. .hisbox{
  351. width: 90%;
  352. margin: 70rpx auto 0;
  353. .hisbox_hint{
  354. width: 100%;
  355. text-align: center;
  356. font-size: 28rpx;
  357. height: 100rpx;
  358. line-height: 100rpx;
  359. color: #999999;
  360. }
  361. .hisbox_item{
  362. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.08);
  363. padding: 20rpx;
  364. margin-bottom: 30rpx;
  365. font-size: 28rpx;
  366. .task_box_left{
  367. display: flex;
  368. margin-bottom: 20rpx;
  369. justify-content: space-between;
  370. }
  371. .task_box_con{
  372. color: #999999;
  373. }
  374. }
  375. }
  376. </style>