SubTitle.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <div class="border-style">
  3. <div class="inner-style">
  4. <div class="white-border"></div>
  5. <div class="align-center">
  6. <div class="name">{{ name }}</div>
  7. <div class="storage" v-if="num">{{ num }}</div>
  8. <div class="statement">{{ statement }}</div>
  9. </div>
  10. <div class="exchange-store" v-if="step">
  11. <div class="store-list active" @click="changePower">开始换电</div>
  12. <div class="store-list" @click="FireControlStoreHouse">消防换仓</div>
  13. <div class="store-list" @click="CheckStoreHouse">检修换仓</div>
  14. <div class="store-list" @click="resetMachine">机器人复位</div>
  15. </div>
  16. </div>
  17. <div class="rolemanage">
  18. <el-dialog :title="dialogType === 'check' ? '检修换仓' : '消防换仓'" :visible.sync="dialogStoreVisible">
  19. <el-form :model="StoreForm" :rules="rules" ref="StoreForm">
  20. <el-form-item :label="dialogType === 'check' ? '检修仓:' : '故障仓:'" :label-width="formLabelWidth"
  21. prop="currentStore">
  22. <el-select v-model="StoreForm.currentStore" clearable
  23. :placeholder="dialogType === 'check' ? '请选择检修仓' : '请选择故障仓'">
  24. <el-option label="01仓" value="1"></el-option>
  25. <el-option label="02仓" value="2"></el-option>
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="目标仓:" :label-width="formLabelWidth" prop="targetStore">
  29. <el-select v-model="StoreForm.targetStore" clearable placeholder="请选择目标仓">
  30. <el-option label="01仓" value="1"></el-option>
  31. <el-option label="02仓" value="2"></el-option>
  32. </el-select>
  33. </el-form-item>
  34. </el-form>
  35. <div slot="footer" class="dialog-footer">
  36. <el-button @click="dialogStoreVisible = false" class="exit">取 消</el-button>
  37. <el-button type="primary" @click="ChangeStore('StoreForm')" class="save">确 定</el-button>
  38. </div>
  39. </el-dialog>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import { beginSwap, fireStore, mtStore, resetRobot } from '@/api/equipment'
  45. export default {
  46. name: "SubTitle",
  47. props: ["name", "statement", "num", "step"],
  48. data() {
  49. var checkcurrentStore = (rule, value, callback) => {
  50. if (!value) {
  51. return callback(new Error(`请选择${this.dialogType === 'check' ? '检修仓' : '故障仓'}`));
  52. } else {
  53. callback()
  54. }
  55. };
  56. var checktargetStore = (rule, value, callback) => {
  57. if (!value) {
  58. callback(new Error('请选择目标仓位'));
  59. } else if (value === this.StoreForm.currentStore) {
  60. callback(new Error(`${this.dialogType === 'check' ? '检修仓' : '故障仓'}不可与目标仓位重名`));
  61. } else {
  62. callback()
  63. }
  64. };
  65. return {
  66. dialogType: 'fire',
  67. dialogStoreVisible: false,
  68. StoreForm: {
  69. currentStore: null,
  70. targetStore: null,
  71. },
  72. rules: {
  73. currentStore: [
  74. { validator: checkcurrentStore, trigger: 'blur' }
  75. ],
  76. targetStore: [
  77. { validator: checktargetStore, trigger: 'blur' }
  78. ],
  79. },
  80. formLabelWidth: '120px',
  81. }
  82. },
  83. methods: {
  84. //手动发起换电
  85. changePower() {
  86. this.$confirm('请确认站控系统手动发起换电?', '开始换电', {
  87. confirmButtonText: '确认',
  88. cancelButtonText: '取消',
  89. type: 'warning'
  90. })
  91. .then(async () => {
  92. const res = await beginSwap()
  93. console.log(res)
  94. this.$message({
  95. type: 'success',
  96. message: '操作成功!'
  97. })
  98. })
  99. .catch(err => { console.error(err) })
  100. },
  101. //机器人复位
  102. resetMachine() {
  103. this.$confirm('请确认机器人复位?', '机器人复位', {
  104. confirmButtonText: '确认',
  105. cancelButtonText: '取消',
  106. type: 'warning'
  107. })
  108. .then(async () => {
  109. const res = await resetRobot()
  110. console.log(res)
  111. this.$message({
  112. type: 'success',
  113. message: '操作成功!'
  114. })
  115. })
  116. .catch(err => { console.error(err) })
  117. },
  118. //检修消防换仓,显示弹窗
  119. CheckStoreHouse() {
  120. this.dialogType = 'check'
  121. this.dialogStoreVisible = true
  122. },
  123. FireControlStoreHouse() {
  124. this.dialogType = 'fire'
  125. this.dialogStoreVisible = true
  126. },
  127. //检修换仓、消防换仓下发指令
  128. ChangeStore(formName) {
  129. this.$refs[formName].validate(valid => {
  130. if (valid) {
  131. const params = this.StoreForm
  132. //检修换仓
  133. if (this.dialogType === 'check') {
  134. mtStore(params).then(res => {
  135. if (res.code === 0) {
  136. this.loading = false;
  137. this.dialogStoreVisible = false;
  138. this.$message({
  139. type: 'success',
  140. message: '操作成功!'
  141. })
  142. this.resetForm()
  143. } else {
  144. this.loading = false;
  145. return this.$message.error(res.msg);
  146. }
  147. })
  148. }
  149. //消防换仓
  150. else {
  151. fireStore(params).then(res => {
  152. if (res.code === 0) {
  153. this.loading = false;
  154. this.dialogStoreVisible = false;
  155. this.$message({
  156. type: 'success',
  157. message: '操作成功!'
  158. })
  159. this.resetForm()
  160. } else {
  161. this.loading = false;
  162. return this.$message.error(res.msg);
  163. }
  164. })
  165. }
  166. }
  167. });
  168. },
  169. //清空下拉仓位
  170. resetForm() {
  171. this.StoreForm.currentStore = null
  172. this.StoreForm.targetStore = null
  173. }
  174. }
  175. };
  176. </script>
  177. <style scoped>
  178. .border-style {
  179. border: 2px solid rgb(25, 34, 51);
  180. border-left: none;
  181. border-right: none;
  182. padding: 2px;
  183. }
  184. .inner-style {
  185. background: #121a29;
  186. padding: 3px;
  187. display: flex;
  188. height: 32px;
  189. flex-direction: row;
  190. }
  191. .white-border {
  192. width: 28px;
  193. height: 18px;
  194. background-image: url("../assets/ico2.png");
  195. background-size: 100% 100%;
  196. }
  197. .align-center {
  198. display: flex;
  199. flex-direction: row;
  200. margin: 0 5px;
  201. align-items: center;
  202. }
  203. .name {
  204. color: white;
  205. font-size: 1.2rem;
  206. font-weight: 600;
  207. text-shadow: 0 0 3px #1753ce, 0 0 4px #1753ce, 0 0 3px #1753ce, 0 0 3px #1753ce;
  208. margin-left: -4.2%;
  209. }
  210. .storage {
  211. background: #192b7d;
  212. width: 20px;
  213. height: 20px;
  214. color: white;
  215. font-size: 16px;
  216. font-weight: 600;
  217. border-radius: 50%;
  218. text-indent: 6px;
  219. line-height: 22px;
  220. margin-left: 3px;
  221. }
  222. .statement {
  223. color: #324264;
  224. font-size: 0.6rem;
  225. margin: 0 8px;
  226. font-weight: 600;
  227. padding-top: 9px;
  228. }
  229. .exchange-store {
  230. flex: 1;
  231. height: 32px;
  232. position: relative;
  233. bottom: 3px;
  234. display: flex;
  235. justify-content: flex-end;
  236. }
  237. .store-list {
  238. width: 88px;
  239. height: 32px;
  240. text-align: center;
  241. line-height: 32px;
  242. border: #414a63 solid 1px;
  243. color: #84988c;
  244. font-size: 14px;
  245. font-weight: 600;
  246. margin-right: 15px;
  247. cursor: pointer;
  248. }
  249. .active {
  250. border: #91fdb9 solid 1px;
  251. color: #91fdb9;
  252. }
  253. </style>