powerCutAdd.vue 8.1 KB

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