| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- <template>
- <wrapper
- fill
- margin
- padding
- background
- >
- <schema-table
- ref="table"
- :schema="schema"
- />
- <confirm-dialog
- ref="editDialog"
- title="新增多功能卡"
- @confirm="onConfirm"
- >
- <div class="c-grid-form u-align-self--center">
- <span class="c-grid-form__label u-required">厂商</span>
- <schema-select
- ref="manufacturer"
- v-model="item.manufacturerKey"
- class="u-width"
- placeholder="请选择厂商"
- :schema="manufacturerSelectSchema"
- />
- <span class="c-grid-form__label u-required">型号</span>
- <el-input
- v-model.trim="item.model"
- placeholder="最多50个字符"
- maxlength="50"
- clearable
- />
- <span class="c-grid-form__label">端口数</span>
- <el-input-number
- v-model="item.portCount"
- :min="0"
- :max="86400"
- step-strictly
- />
- <span class="c-grid-form__label">485接口数</span>
- <el-input-number
- v-model="item.rs485Count"
- :min="0"
- :max="86400"
- step-strictly
- />
- <span class="c-grid-form__label u-required">唯一标识</span>
- <el-input
- v-model.trim="item.identifier"
- placeholder="最多50个字符"
- maxlength="50"
- clearable
- />
- </div>
- </confirm-dialog>
- <mesh-dialog ref="meshDialog" />
- </wrapper>
- </template>
- <script>
- import { ThirdPartyDevice } from '@/constant'
- import {
- getManufacturersByType,
- getMultifunctionCards,
- addMultifunctionCard,
- deleteMultifunctionCard
- } from '@/api/external'
- import MeshDialog from '../components/MeshDialog.vue'
- export default {
- name: 'MultifunctionCardList',
- components: {
- MeshDialog
- },
- data () {
- const manufacturerSelectSchema = {
- remote: this.getManufacturersByType,
- value: 'manufacturerKey',
- label: 'manufacturerName'
- }
- return {
- item: {},
- manufacturerSelectSchema,
- schema: {
- list: getMultifunctionCards,
- buttons: [
- { type: 'add', on: this.onAdd }
- ],
- filters: [
- { key: 'manufacturerKey', type: 'select', placeholder: '厂商', ...manufacturerSelectSchema },
- { key: 'boundFlag', type: 'select', placeholder: '使用情况', options: [
- { value: 0, label: '已使用' },
- { value: 1, label: '未使用' }
- ] },
- { key: 'identifier', type: 'search', placeholder: '唯一标识' }
- ],
- cols: [
- { prop: 'manufacturerName', label: '厂商' },
- { prop: 'model', label: '型号' },
- { prop: 'identifier', label: '唯一标识' },
- { prop: 'portCount', label: '端口数', align: 'center' },
- { prop: 'rs485Count', label: '485接口数', align: 'center' },
- { label: '使用情况', type: 'tag', render: ({ bound }) => bound
- ? { type: 'success', label: '已使用' }
- : { type: 'primary', label: '未使用' } },
- { type: 'invoke', render: [
- { label: '所属网点', allow: ({ bound }) => bound, on: this.onViewMesh },
- { label: '删除', allow: ({ bound }) => !bound, on: this.onDel }
- ], width: 200 }
- ]
- }
- }
- },
- methods: {
- getManufacturersByType () {
- return getManufacturersByType(ThirdPartyDevice.MULTI_FUNCTION_CARD)
- },
- onAdd () {
- this.item = {
- identifier: '',
- manufacturerKey: '',
- model: '',
- portCount: 0,
- rs485Count: 0
- }
- this.$refs.editDialog.show()
- },
- onConfirm (done) {
- if (!this.item.manufacturerKey) {
- this.$message({
- type: 'warning',
- message: '请选择厂商'
- })
- return
- }
- if (!this.item.model) {
- this.$message({
- type: 'warning',
- message: '请填写型号'
- })
- return
- }
- if (!this.item.identifier) {
- this.$message({
- type: 'warning',
- message: '请填写唯一标识'
- })
- return
- }
- const key = this.item.manufacturerKey
- addMultifunctionCard({
- manufacturerName: this.$refs.manufacturer.getOptions().find(({ value }) => value === key).label,
- ...this.item
- }).then(() => {
- done()
- this.$refs.table.resetCondition({
- manufacturerKey: key,
- identifier: this.item.identifier
- })
- })
- },
- onDel (item) {
- deleteMultifunctionCard(item).then(() => {
- this.$refs.table.decrease(1)
- })
- },
- onViewMesh ({ id }) {
- this.$refs.meshDialog.show(id)
- }
- }
- }
- </script>
|