powerCutAdd.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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 in siteListData">{{ 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 in siteListData">{{ 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"></input>
  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"></input>
  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. noClick:true,
  115. id:'',
  116. isShow: false,
  117. formMess: {
  118. "site_id": 0,
  119. "plan_type": 0,
  120. "start_time": "",
  121. "end_time": "",
  122. },
  123. siteListData:[],
  124. planTypeData:[],
  125. planDetailData:{},
  126. start_time: '',
  127. end_time: '',
  128. }
  129. },
  130. onLoad: function(option) {
  131. this.getSiteList();
  132. this.id=option.id;
  133. this.status_value=option.status_value
  134. if (option.id) {
  135. uni.setNavigationBarTitle({
  136. title: '计划停电修改'
  137. });
  138. this.getDataList({
  139. "id": option.id,
  140. "status_value": option.status_value
  141. })
  142. } else {
  143. uni.setNavigationBarTitle({
  144. title: '计划停电新增'
  145. });
  146. }
  147. },
  148. methods: {
  149. //新增验证并提交
  150. addSubmit() {
  151. // alert( this.formMess.start_time)
  152. if (!this.start_time) {
  153. uni.showToast({
  154. title: "请选择开始时间",
  155. icon: "none"
  156. });
  157. return
  158. }
  159. if (!this.end_time) {
  160. uni.showToast({
  161. title: "请选择结束时间",
  162. icon: "none"
  163. });
  164. return
  165. }
  166. if (this.end_time<this.start_time) {
  167. uni.showToast({
  168. title: "结束时间不能小于开始时间,请重新选择",
  169. icon: "none"
  170. });
  171. return
  172. }
  173. if (!this.formMess.site_id) {
  174. uni.showToast({
  175. title: "请选择所属站点",
  176. icon: "none"
  177. });
  178. return
  179. }
  180. if (!this.formMess.plan_type) {
  181. uni.showToast({
  182. title: "请选择计划类型",
  183. icon: "none"
  184. });
  185. return
  186. }
  187. this.setAddDevice({
  188. "site_id": this.formMess.site_id,
  189. "plan_type": this.formMess.plan_type,
  190. "start_time": this.start_time,
  191. "end_time": this.end_time,
  192. })
  193. },
  194. // 新增请求
  195. async setAddDevice(ming = {}) {
  196. const res = await this.$myRequest({
  197. url: 'BlackoutPlan/addBlackoutPlan',
  198. data: ming
  199. })
  200. if (!res.data.flag) {
  201. uni.showToast({
  202. title: "添加失败",
  203. icon: "none"
  204. });
  205. } else {
  206. uni.showToast({
  207. title: "添加成功",
  208. });
  209. }
  210. setTimeout(() => {
  211. uni.navigateTo({
  212. url: '/pages/eleControl/powerCut/powerCut'
  213. });
  214. }, 1000);
  215. },
  216. // 修改回显请求
  217. async getDataList(params = {}) {
  218. const res = await this.$myRequest({
  219. url: 'BlackoutPlan/getBlackoutPlanList',
  220. showLoading: true,
  221. data: params
  222. })
  223. console.log('res.data.data')
  224. console.log(res.data.data)
  225. this.planDetailData = res.data.data[0],
  226. this.start_time=this.planDetailData.start_time
  227. console.log(this.planDetailData.start_time)
  228. },
  229. //编辑验证并提交
  230. editSubmit() {
  231. if (this.planDetailData.end_time<this.planDetailData.start_time) {
  232. uni.showToast({
  233. title: "结束时间不能小于开始时间,请重新选择",
  234. icon: "none"
  235. });
  236. return
  237. }
  238. this.updataPlan({
  239. "site_id": this.planDetailData.site_id,
  240. "plan_type": this.planDetailData.plan_type,
  241. "start_time": this.planDetailData.start_time,
  242. "end_time": this.planDetailData.end_time,
  243. "creator": this.planDetailData.creator,
  244. "phone": this.planDetailData.phone,
  245. "id":this.planDetailData.id,
  246. })
  247. },
  248. // 编辑请求
  249. async updataPlan(ming = {}) {
  250. const res = await this.$myRequest({
  251. url: 'BlackoutPlan/updateBlackoutPlan',
  252. data: ming
  253. })
  254. if (!res.data.flag) {
  255. uni.showToast({
  256. title: "编辑失败",
  257. icon: "none"
  258. });
  259. } else {
  260. uni.showToast({
  261. title: "编辑成功",
  262. });
  263. }
  264. setTimeout(() => {
  265. uni.navigateTo({
  266. url: '/pages/eleControl/powerCut/powerCut'
  267. });
  268. }, 1000);
  269. },
  270. //站带下拉数据请求
  271. async getSiteList(params = {}) {
  272. const res = await this.$myRequest({
  273. url: 'BlackoutPlan/getSiteBox',
  274. showLoading: true,
  275. data: params
  276. })
  277. this.siteListData = res.data.data
  278. },
  279. }
  280. }
  281. </script>
  282. <style lang="scss">
  283. /deep/ .uni-calendar--fixed{
  284. z-index:1111!important
  285. }
  286. .example-body{
  287. width: 276px;
  288. font-size: 15px;
  289. /deep/ uni-input, select, option{
  290. border:none
  291. }
  292. }
  293. </style>