|
|
@@ -20,12 +20,12 @@
|
|
|
</button>
|
|
|
</div>
|
|
|
<el-select
|
|
|
- v-model="options.params.manufacturerId"
|
|
|
- class="l-flex__fill c-info__value"
|
|
|
+ v-model="options.params.manufacturerKey"
|
|
|
+ class="l-flex__none c-sibling-item"
|
|
|
placeholder="请选择厂家"
|
|
|
:loading="manufacturers.loading"
|
|
|
- @visible-change="getReceivingCardManufacturers"
|
|
|
- @change="onChangeProp('manufacturerId')"
|
|
|
+ @visible-change="getManufacturers"
|
|
|
+ @change="search"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="manufacturer in manufacturerList"
|
|
|
@@ -36,7 +36,7 @@
|
|
|
</el-select>
|
|
|
</template>
|
|
|
<el-table-column
|
|
|
- prop="manufacturer"
|
|
|
+ prop="manufacturerName"
|
|
|
label="厂商"
|
|
|
align="center"
|
|
|
show-overflow-tooltip
|
|
|
@@ -48,20 +48,14 @@
|
|
|
show-overflow-tooltip
|
|
|
/>
|
|
|
<el-table-column
|
|
|
- prop="model"
|
|
|
+ prop="type"
|
|
|
label="设备型号"
|
|
|
align="center"
|
|
|
show-overflow-tooltip
|
|
|
/>
|
|
|
<el-table-column
|
|
|
- prop="isSync"
|
|
|
- label="异步盒"
|
|
|
- align="center"
|
|
|
- show-overflow-tooltip
|
|
|
- />
|
|
|
- <el-table-column
|
|
|
- prop="通信方式"
|
|
|
- label="protocal"
|
|
|
+ prop="remark"
|
|
|
+ label="备注"
|
|
|
align="center"
|
|
|
show-overflow-tooltip
|
|
|
/>
|
|
|
@@ -86,104 +80,66 @@
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</c-table>
|
|
|
- <el-dialog
|
|
|
- title="添加发送控制设备"
|
|
|
- :visible.sync="show"
|
|
|
- custom-class="c-dialog"
|
|
|
- :close-on-click-modal="false"
|
|
|
- :before-close="close"
|
|
|
+ <confirm-dialog
|
|
|
+ ref="editDialog"
|
|
|
+ :title="dialogTitle"
|
|
|
+ @confirm="onConfirm"
|
|
|
>
|
|
|
- <div class="c-form">
|
|
|
- <div class="c-form__section">
|
|
|
- <span class="c-form__label large required">厂家:</span>
|
|
|
- <el-select
|
|
|
- v-model="transmitter.manufacturerId"
|
|
|
- class="c-form__item"
|
|
|
- placeholder="请选择厂家"
|
|
|
- :loading="manufacturers.loading"
|
|
|
- @visible-change="getReceivingCardManufacturers"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="manufacturer in manufacturers.list"
|
|
|
- :key="manufacturer.value"
|
|
|
- :label="manufacturer.label"
|
|
|
- :value="manufacturer.value"
|
|
|
- />
|
|
|
- </el-select>
|
|
|
- </div>
|
|
|
- <div class="c-form__section">
|
|
|
- <span class="c-form__label large required">设备名称:</span>
|
|
|
- <el-input
|
|
|
- v-model.trim="transmitter.name"
|
|
|
- class="c-form__item"
|
|
|
- maxlength="50"
|
|
|
- show-word-limit
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div class="c-form__section">
|
|
|
- <span class="c-form__label large required">设备型号:</span>
|
|
|
- <el-input
|
|
|
- v-model.trim="transmitter.model"
|
|
|
- class="c-form__item"
|
|
|
- maxlength="50"
|
|
|
- show-word-limit
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div class="c-form__section">
|
|
|
- <span class="c-form__label large required">通信类型:</span>
|
|
|
- <el-select
|
|
|
- v-model="transmitter.protocol"
|
|
|
- class="c-form__item"
|
|
|
- placeholder="请选择"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="protocol in protocols"
|
|
|
- :key="protocol.value"
|
|
|
- :label="protocol.label"
|
|
|
- :value="protocol.value"
|
|
|
- />
|
|
|
- </el-select>
|
|
|
- </div>
|
|
|
- <div class="c-form__section">
|
|
|
- <span class="c-form__label large">是否为异步盒:</span>
|
|
|
- <el-switch
|
|
|
- v-model="transmitter.async"
|
|
|
- class="c-form__item"
|
|
|
- active-color="#13ce66"
|
|
|
- inactive-color="#ff4949"
|
|
|
+ <div class="c-grid-form u-align-self--center">
|
|
|
+ <span class="c-grid-form__label required">厂商:</span>
|
|
|
+ <el-select
|
|
|
+ v-model="transmitter.manufacturerKey"
|
|
|
+ placeholder="请选择厂家"
|
|
|
+ :loading="manufacturers.loading"
|
|
|
+ @visible-change="getManufacturers"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="manufacturer in manufacturers.list"
|
|
|
+ :key="manufacturer.value"
|
|
|
+ :label="manufacturer.label"
|
|
|
+ :value="manufacturer.value"
|
|
|
/>
|
|
|
- </div>
|
|
|
+ </el-select>
|
|
|
+ <span class="c-grid-form__label required">设备名称:</span>
|
|
|
+ <el-input
|
|
|
+ v-model.trim="transmitter.name"
|
|
|
+ maxlength="50"
|
|
|
+ show-word-limit
|
|
|
+ />
|
|
|
+ <span class="c-grid-form__label required">设备型号:</span>
|
|
|
+ <el-input
|
|
|
+ v-model.trim="transmitter.type"
|
|
|
+ maxlength="50"
|
|
|
+ show-word-limit
|
|
|
+ />
|
|
|
+ <span class="c-grid-form__label">备注:</span>
|
|
|
+ <el-input
|
|
|
+ v-model="transmitter.remark"
|
|
|
+ type="textarea"
|
|
|
+ :rows="3"
|
|
|
+ maxlength="100"
|
|
|
+ show-word-limit
|
|
|
+ />
|
|
|
</div>
|
|
|
- <template #footer>
|
|
|
- <button
|
|
|
- class="o-button"
|
|
|
- @click="save"
|
|
|
- >
|
|
|
- 确定
|
|
|
- </button>
|
|
|
- <button
|
|
|
- class="o-button cancel"
|
|
|
- @click="close"
|
|
|
- >
|
|
|
- 取消
|
|
|
- </button>
|
|
|
- </template>
|
|
|
- </el-dialog>
|
|
|
+ </confirm-dialog>
|
|
|
</wrapper>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import {
|
|
|
- getDevices,
|
|
|
- getReceivingCardManufacturers
|
|
|
-} from '@/api/device'
|
|
|
+ getSendCardManufacturers,
|
|
|
+ getSendCards,
|
|
|
+ addSendCard,
|
|
|
+ updateSendCard,
|
|
|
+ deleteSendCard
|
|
|
+} from '@/api/external'
|
|
|
import { createListOptions } from '@/utils'
|
|
|
|
|
|
export default {
|
|
|
name: 'Transmitter',
|
|
|
data () {
|
|
|
return {
|
|
|
- options: createListOptions({ manufacturerId: '' }),
|
|
|
+ options: createListOptions({ manufacturerKey: void 0 }),
|
|
|
manufacturers: {
|
|
|
loading: false,
|
|
|
loaded: false,
|
|
|
@@ -199,7 +155,17 @@ export default {
|
|
|
},
|
|
|
computed: {
|
|
|
manufacturerList () {
|
|
|
- return [{ value: '', label: '全部厂家' }]
|
|
|
+ return [{ value: void 0, label: '全部厂家' }].concat(this.manufacturers.list)
|
|
|
+ },
|
|
|
+ manufacturerKeys () {
|
|
|
+ return this.manufacturers.loaded
|
|
|
+ ? this.manufacturers.list
|
|
|
+ : this.transmitter.id
|
|
|
+ ? []
|
|
|
+ : [{ value: this.transmitter.manufacturerKey, label: this.manufacturerName }]
|
|
|
+ },
|
|
|
+ dialogTitle () {
|
|
|
+ return this.transmitter.id ? '添加发送控制设备' : '修改发送控制设备'
|
|
|
}
|
|
|
},
|
|
|
created () {
|
|
|
@@ -217,7 +183,7 @@ export default {
|
|
|
const options = this.options
|
|
|
options.error = false
|
|
|
options.loading = true
|
|
|
- return getDevices(options).then(({ data, totalCount }) => {
|
|
|
+ return getSendCards(options.params).then(({ data, totalCount }) => {
|
|
|
options.list = data
|
|
|
options.totalCount = totalCount
|
|
|
}, () => {
|
|
|
@@ -227,12 +193,12 @@ export default {
|
|
|
options.loading = false
|
|
|
})
|
|
|
},
|
|
|
- getReceivingCardManufacturers (visible) {
|
|
|
+ getManufacturers (visible) {
|
|
|
if (visible && !this.manufacturers.loading && !this.manufacturers.loaded) {
|
|
|
this.manufacturers.loading = true
|
|
|
- getReceivingCardManufacturers().then(({ data }) => {
|
|
|
- this.manufacturers.list = data.map(({ id, name }) => {
|
|
|
- return { value: id, label: name }
|
|
|
+ getSendCardManufacturers().then(({ data }) => {
|
|
|
+ this.manufacturers.list = data.map(({ manufacturerKey, manufacturerName }) => {
|
|
|
+ return { value: manufacturerKey, label: manufacturerName }
|
|
|
})
|
|
|
this.manufacturers.loading = false
|
|
|
this.manufacturers.loaded = true
|
|
|
@@ -243,19 +209,71 @@ export default {
|
|
|
},
|
|
|
onAdd () {
|
|
|
this.transmitter = {
|
|
|
- manufacturerId: '',
|
|
|
+ manufacturerKey: '',
|
|
|
name: '',
|
|
|
- model: '',
|
|
|
- protocol: '',
|
|
|
- async: false
|
|
|
+ type: '',
|
|
|
+ flag: 0,
|
|
|
+ remark: ''
|
|
|
}
|
|
|
- this.show = true
|
|
|
+ this.$refs.editDialog.show()
|
|
|
},
|
|
|
- close () {
|
|
|
- this.show = false
|
|
|
+ onEdit ({ id, manufacturerKey, manufacturerName, name, type, flag, remark }) {
|
|
|
+ this.manufacturerName = manufacturerName
|
|
|
+ this.transmitter = { id, manufacturerKey, name, type, flag, remark }
|
|
|
+ this.$refs.editDialog.show()
|
|
|
},
|
|
|
- save () {
|
|
|
-
|
|
|
+ onConfirm (done) {
|
|
|
+ if (!this.transmitter.manufacturerKey) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请选择厂商'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!this.transmitter.name) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请填写设备名称'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!this.transmitter.type) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请填写设备型号'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.transmitter.id) {
|
|
|
+ this.onConfirmEdit(done)
|
|
|
+ } else {
|
|
|
+ this.onConfirmAdd(done)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onConfirmAdd (done) {
|
|
|
+ addSendCard(this.transmitter).then(() => {
|
|
|
+ done()
|
|
|
+ const params = this.options.params
|
|
|
+ if (params.manufacturerKey && params.manufacturerKey !== this.transmitter.manufacturerKey) {
|
|
|
+ params.manufacturerKey = void 0
|
|
|
+ }
|
|
|
+ this.search()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onConfirmEdit (done) {
|
|
|
+ updateSendCard(this.transmitter).then(() => {
|
|
|
+ done()
|
|
|
+ this.getList()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onDel (item) {
|
|
|
+ deleteSendCard(item).then(() => {
|
|
|
+ const options = this.options
|
|
|
+ if (options.list.length === 1 && options.params.pageNum > 1) {
|
|
|
+ options.params.pageNum -= 1
|
|
|
+ }
|
|
|
+ this.getList()
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|