123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- <template>
- <div class="border-style">
- <div class="inner-style">
- <div class="white-border"></div>
- <div class="align-center">
- <div class="name">{{ name }}</div>
- <div class="storage" v-if="num">{{ num }}</div>
- <div class="statement">{{ statement }}</div>
- </div>
- <div class="exchange-store" v-if="step">
- <div class="store-list active" @click="changePower">开始换电</div>
- <div class="store-list" @click="FireControlStoreHouse">消防换仓</div>
- <div class="store-list" @click="CheckStoreHouse">检修换仓</div>
- <div class="store-list" @click="resetMachine">机器人复位</div>
- </div>
- </div>
- <div class="rolemanage">
- <el-dialog :title="dialogType === 'check' ? '检修换仓' : '消防换仓'" :visible.sync="dialogStoreVisible">
- <el-form :model="StoreForm" :rules="rules" ref="StoreForm">
- <el-form-item :label="dialogType === 'check' ? '检修仓:' : '故障仓:'" :label-width="formLabelWidth"
- prop="currentStore">
- <el-select v-model="StoreForm.currentStore" clearable
- :placeholder="dialogType === 'check' ? '请选择检修仓' : '请选择故障仓'">
- <el-option label="01仓" value="1"></el-option>
- <el-option label="02仓" value="2"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="目标仓:" :label-width="formLabelWidth" prop="targetStore">
- <el-select v-model="StoreForm.targetStore" clearable placeholder="请选择目标仓">
- <el-option label="01仓" value="1"></el-option>
- <el-option label="02仓" value="2"></el-option>
- </el-select>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="dialogStoreVisible = false" class="exit">取 消</el-button>
- <el-button type="primary" @click="ChangeStore('StoreForm')" class="save">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </div>
- </template>
- <script>
- import { beginSwap, fireStore, mtStore, resetRobot } from '@/api/equipment'
- export default {
- name: "SubTitle",
- props: ["name", "statement", "num", "step"],
- data() {
- var checkcurrentStore = (rule, value, callback) => {
- if (!value) {
- return callback(new Error(`请选择${this.dialogType === 'check' ? '检修仓' : '故障仓'}`));
- } else {
- callback()
- }
- };
- var checktargetStore = (rule, value, callback) => {
- if (!value) {
- callback(new Error('请选择目标仓位'));
- } else if (value === this.StoreForm.currentStore) {
- callback(new Error(`${this.dialogType === 'check' ? '检修仓' : '故障仓'}不可与目标仓位重名`));
- } else {
- callback()
- }
- };
- return {
- dialogType: 'fire',
- dialogStoreVisible: false,
- StoreForm: {
- currentStore: null,
- targetStore: null,
- },
- rules: {
- currentStore: [
- { validator: checkcurrentStore, trigger: 'blur' }
- ],
- targetStore: [
- { validator: checktargetStore, trigger: 'blur' }
- ],
- },
- formLabelWidth: '120px',
- }
- },
- methods: {
- //手动发起换电
- changePower() {
- this.$confirm('请确认站控系统手动发起换电?', '开始换电', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(async () => {
- const res = await beginSwap()
- console.log(res)
- this.$message({
- type: 'success',
- message: '操作成功!'
- })
- })
- .catch(err => { console.error(err) })
- },
- //机器人复位
- resetMachine() {
- this.$confirm('请确认机器人复位?', '机器人复位', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(async () => {
- const res = await resetRobot()
- console.log(res)
- this.$message({
- type: 'success',
- message: '操作成功!'
- })
- })
- .catch(err => { console.error(err) })
- },
- //检修消防换仓,显示弹窗
- CheckStoreHouse() {
- this.dialogType = 'check'
- this.dialogStoreVisible = true
- },
- FireControlStoreHouse() {
- this.dialogType = 'fire'
- this.dialogStoreVisible = true
- },
- //检修换仓、消防换仓下发指令
- ChangeStore(formName) {
- this.$refs[formName].validate(valid => {
- if (valid) {
- const params = this.StoreForm
- //检修换仓
- if (this.dialogType === 'check') {
- mtStore(params).then(res => {
- if (res.code === 0) {
- this.loading = false;
- this.dialogStoreVisible = false;
- this.$message({
- type: 'success',
- message: '操作成功!'
- })
- this.resetForm()
- } else {
- this.loading = false;
- return this.$message.error(res.msg);
- }
- })
- }
- //消防换仓
- else {
- fireStore(params).then(res => {
- if (res.code === 0) {
- this.loading = false;
- this.dialogStoreVisible = false;
- this.$message({
- type: 'success',
- message: '操作成功!'
- })
- this.resetForm()
- } else {
- this.loading = false;
- return this.$message.error(res.msg);
- }
- })
- }
- }
- });
- },
- //清空下拉仓位
- resetForm() {
- this.StoreForm.currentStore = null
- this.StoreForm.targetStore = null
- }
- }
- };
- </script>
- <style scoped>
- .border-style {
- border: 2px solid rgb(25, 34, 51);
- border-left: none;
- border-right: none;
- padding: 2px;
- }
- .inner-style {
- background: #121a29;
- padding: 3px;
- display: flex;
- height: 32px;
- flex-direction: row;
- }
- .white-border {
- width: 28px;
- height: 18px;
- background-image: url("../assets/ico2.png");
- background-size: 100% 100%;
- }
- .align-center {
- display: flex;
- flex-direction: row;
- margin: 0 5px;
- align-items: center;
- }
- .name {
- color: white;
- font-size: 1.2rem;
- font-weight: 600;
- text-shadow: 0 0 3px #1753ce, 0 0 4px #1753ce, 0 0 3px #1753ce, 0 0 3px #1753ce;
- margin-left: -4.2%;
- }
- .storage {
- background: #192b7d;
- width: 20px;
- height: 20px;
- color: white;
- font-size: 16px;
- font-weight: 600;
- border-radius: 50%;
- text-indent: 6px;
- line-height: 22px;
- margin-left: 3px;
- }
- .statement {
- color: #324264;
- font-size: 0.6rem;
- margin: 0 8px;
- font-weight: 600;
- padding-top: 9px;
- }
- .exchange-store {
- flex: 1;
- height: 32px;
- position: relative;
- bottom: 3px;
- display: flex;
- justify-content: flex-end;
- }
- .store-list {
- width: 88px;
- height: 32px;
- text-align: center;
- line-height: 32px;
- border: #414a63 solid 1px;
- color: #84988c;
- font-size: 14px;
- font-weight: 600;
- margin-right: 15px;
- cursor: pointer;
- }
- .active {
- border: #91fdb9 solid 1px;
- color: #91fdb9;
- }
- </style>
|