powerCutAdd.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <view class="appWrapper">
  3. <form action="" v-if="!id">
  4. <view style="height:30rpx"></view>
  5. <view class="form-item">
  6. <view class="title">
  7. <text class="necessary">*</text>
  8. 开始时间:
  9. </view>
  10. <view class="example-body">
  11. <uni-datetime-picker v-model="start_time" />
  12. </view>
  13. </view>
  14. <view class="form-item">
  15. <view class="title">
  16. <text class="necessary">*</text>
  17. 结束时间:
  18. </view>
  19. <view class="example-body">
  20. <uni-datetime-picker v-model="end_time" :start="start_time" />
  21. </view>
  22. </view>
  23. <!-- <calendar @func='getMsgFromxSon' @func2='getMsgFromxSon2' :bindStartTime="formMess.start_time" :bindEndTime="formMess.end_time"></calendar> -->
  24. <view class="form-item">
  25. <view class="title"><text class="necessary">*</text>所属站点:</view>
  26. <select name="" id="" filterable clearable v-model="formMess.site_id">
  27. <option value="0">请选择</option>
  28. <option :value=item.id v-for="(item,index) in siteListData" :key="index">{{ item.site_name}}</option>
  29. </select>
  30. </view>
  31. <view class="form-item">
  32. <view class="title"><text class="necessary">*</text>计划类型:</view>
  33. <select name="" id="" filterable clearable v-model="formMess.plan_type">
  34. <option value="0">请选择</option>
  35. <option value="1">计划检修停电</option>
  36. <option value="2">计划施工停电</option>
  37. <option value="3">客户申请停电</option>
  38. </select>
  39. </view>
  40. <view class="btn-area submitBottomBtn padding-lr-sm">
  41. <button class="bg-blue round margin-top" @click="$noMultipleClicks(addSubmit)">提 交 </button>
  42. </view>
  43. </form>
  44. <!-- 修改start -->
  45. <form action="" v-else>
  46. <view style="height:30rpx"></view>
  47. <view class="form-item">
  48. <view class="title">
  49. <text class="necessary">*</text>
  50. 开始时间:
  51. </view>
  52. <view class="example-body" v-if="this.status_value==1">
  53. <uni-datetime-picker v-model="planDetailData.start_time" />
  54. </view>
  55. <view class="example-body" v-else>
  56. <uni-datetime-picker v-model="planDetailData.start_time" disabled />
  57. </view>
  58. </view>
  59. <view class="form-item">
  60. <view class="title">
  61. <text class="necessary">*</text>
  62. 结束时间:
  63. </view>
  64. <view class="example-body">
  65. <uni-datetime-picker v-model="planDetailData.end_time" :start="planDetailData.start_time" />
  66. </view>
  67. </view>
  68. <!-- <calendar @func='getMsgFromxSon' @func2='getMsgFromxSon2' :bindStartTime="planDetailData.start_time" :bindEndTime="planDetailData.end_time" v-if="this.planDetailData.end_time" ></calendar> -->
  69. <view class="form-item">
  70. <view class="title"><text class="necessary">*</text>所属站点:</view>
  71. <select name="" id="" filterable clearable v-model="planDetailData.site_id" disabled="disabled">
  72. <option value="0">请选择</option>
  73. <option :value=item.id v-for="(item,index) in siteListData" :key="index">{{ item.site_name}}</option>
  74. </select>
  75. </view>
  76. <view class="form-item">
  77. <view class="title"><text class="necessary">*</text>计划类型:</view>
  78. <select name="" id="" filterable clearable v-model="planDetailData.plan_type" disabled="disabled">
  79. <option value="0">请选择</option>
  80. <option value="1">计划检修停电</option>
  81. <option value="2">计划施工停电</option>
  82. <option value="3">客户申请停电</option>
  83. </select>
  84. </view>
  85. <view class="form-item margin-top">
  86. <view class="title">
  87. <text class="necessary">*</text>
  88. 报备人:
  89. </view>
  90. <input name="deviceCode" v-model="planDetailData.creator" disabled="disabled"/>
  91. </view>
  92. <view class="form-item margin-top">
  93. <view class="title">
  94. <text class="necessary">*</text>
  95. 手机号:
  96. </view>
  97. <input name="deviceCode" v-model="planDetailData.phone" disabled="disabled"/>
  98. </view>
  99. <view class="btn-area submitBottomBtn padding-lr-sm">
  100. <button class="bg-blue round margin-top" @click="$noMultipleClicks(editSubmit)">提 交 </button>
  101. </view>
  102. </form>
  103. <!-- 修改end -->
  104. </view>
  105. </template>
  106. <script>
  107. // import calendar from '../calendar/calendar.vue';
  108. export default {
  109. components: {
  110. // calendar
  111. },
  112. data() {
  113. return {
  114. single: "2021-04-3",
  115. noClick: true,
  116. id: '',
  117. isShow: false,
  118. formMess: {
  119. "site_id": 0,
  120. "plan_type": 0,
  121. "start_time": "",
  122. "end_time": "",
  123. },
  124. siteListData: [],
  125. planTypeData: [],
  126. planDetailData: {},
  127. start_time: '',
  128. end_time: '',
  129. }
  130. },
  131. onLoad: function(option) {
  132. this.getSiteList();
  133. this.id = option.id;
  134. this.status_value = option.status_value
  135. if (option.id) {
  136. uni.setNavigationBarTitle({
  137. title: '计划停电修改'
  138. });
  139. this.getDataList({
  140. "id": option.id,
  141. "status_value": option.status_value
  142. })
  143. } else {
  144. uni.setNavigationBarTitle({
  145. title: '计划停电新增'
  146. });
  147. }
  148. },
  149. methods: {
  150. change(e) {
  151. this.single = e;
  152. console.log("-change事件:", e);
  153. },
  154. //新增验证并提交
  155. addSubmit() {
  156. // alert( this.formMess.start_time)
  157. if (!this.start_time) {
  158. uni.showToast({
  159. title: "请选择开始时间",
  160. icon: "none"
  161. });
  162. return
  163. }
  164. if (!this.end_time) {
  165. uni.showToast({
  166. title: "请选择结束时间",
  167. icon: "none"
  168. });
  169. return
  170. }
  171. if (this.end_time < this.start_time) {
  172. uni.showToast({
  173. title: "结束时间不能小于开始时间,请重新选择",
  174. icon: "none"
  175. });
  176. return
  177. }
  178. if (!this.formMess.site_id) {
  179. uni.showToast({
  180. title: "请选择所属站点",
  181. icon: "none"
  182. });
  183. return
  184. }
  185. if (!this.formMess.plan_type) {
  186. uni.showToast({
  187. title: "请选择计划类型",
  188. icon: "none"
  189. });
  190. return
  191. }
  192. this.setAddDevice({
  193. "site_id": this.formMess.site_id,
  194. "plan_type": this.formMess.plan_type,
  195. "start_time": this.start_time,
  196. "end_time": this.end_time,
  197. })
  198. },
  199. // 新增请求
  200. async setAddDevice(ming = {}) {
  201. const res = await this.$myRequest({
  202. url: 'BlackoutPlan/addBlackoutPlan',
  203. data: ming
  204. })
  205. if (!res.data.flag) {
  206. uni.showToast({
  207. title: "添加失败",
  208. icon: "none"
  209. });
  210. } else {
  211. uni.showToast({
  212. title: "添加成功",
  213. });
  214. }
  215. setTimeout(() => {
  216. uni.redirectTo({
  217. url: '/pages/eleControl/powerCut/powerCut'
  218. });
  219. }, 1000);
  220. },
  221. // 修改回显请求
  222. async getDataList(params = {}) {
  223. const res = await this.$myRequest({
  224. url: 'BlackoutPlan/getBlackoutPlanList',
  225. showLoading: true,
  226. data: params
  227. })
  228. console.log('res.data.data')
  229. console.log(res.data.data)
  230. this.planDetailData = res.data.data[0],
  231. this.start_time = this.planDetailData.start_time
  232. console.log(this.planDetailData.start_time)
  233. },
  234. //编辑验证并提交
  235. editSubmit() {
  236. if (this.planDetailData.end_time < this.planDetailData.start_time) {
  237. uni.showToast({
  238. title: "结束时间不能小于开始时间,请重新选择",
  239. icon: "none"
  240. });
  241. return
  242. }
  243. this.updataPlan({
  244. "site_id": this.planDetailData.site_id,
  245. "plan_type": this.planDetailData.plan_type,
  246. "start_time": this.planDetailData.start_time,
  247. "end_time": this.planDetailData.end_time,
  248. "creator": this.planDetailData.creator,
  249. "phone": this.planDetailData.phone,
  250. "id": this.planDetailData.id,
  251. })
  252. },
  253. // 编辑请求
  254. async updataPlan(ming = {}) {
  255. const res = await this.$myRequest({
  256. url: 'BlackoutPlan/updateBlackoutPlan',
  257. data: ming
  258. })
  259. if (!res.data.flag) {
  260. uni.showToast({
  261. title: "编辑失败",
  262. icon: "none"
  263. });
  264. } else {
  265. uni.showToast({
  266. title: "编辑成功",
  267. });
  268. }
  269. setTimeout(() => {
  270. uni.redirectTo({
  271. url: '/pages/eleControl/powerCut/powerCut'
  272. });
  273. }, 1000);
  274. },
  275. //站带下拉数据请求
  276. async getSiteList(params = {}) {
  277. const res = await this.$myRequest({
  278. url: 'BlackoutPlan/getSiteBox',
  279. showLoading: true,
  280. data: params
  281. })
  282. this.siteListData = res.data.data
  283. },
  284. }
  285. }
  286. </script>
  287. <style lang="scss">
  288. /deep/ .uni-calendar--fixed {
  289. z-index: 1111 !important
  290. }
  291. .example-body {
  292. width: 276px;
  293. font-size: 15px;
  294. /deep/ uni-input,
  295. select,
  296. option {
  297. border: none
  298. }
  299. }
  300. </style>