powerCutAdd.vue 8.1 KB

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