|
|
@@ -5,22 +5,21 @@
|
|
|
>
|
|
|
<confirm-dialog
|
|
|
ref="editDialog"
|
|
|
- :title="dialogTitle"
|
|
|
+ title="新增屏幕配置"
|
|
|
@confirm="onSave"
|
|
|
>
|
|
|
<div class="c-grid-form u-align-self--center">
|
|
|
<span class="c-grid-form__label u-required">名称</span>
|
|
|
<el-input
|
|
|
v-model.trim="currObj.name"
|
|
|
- placeholder="最多50个字符"
|
|
|
- maxlength="50"
|
|
|
+ placeholder="最多30个字符"
|
|
|
+ maxlength="30"
|
|
|
clearable
|
|
|
/>
|
|
|
<span class="c-grid-form__label u-required">类型</span>
|
|
|
<schema-select
|
|
|
v-model="currObj.productTypeId"
|
|
|
placeholder="请选择屏幕类型"
|
|
|
- :disabled="!isAdd"
|
|
|
:schema="productTypeSelectSchema"
|
|
|
/>
|
|
|
<span class="c-grid-form__label u-required">分辨率</span>
|
|
|
@@ -31,7 +30,6 @@
|
|
|
class="l-flex__auto c-sibling-item"
|
|
|
:min="1"
|
|
|
:max="999999"
|
|
|
- :disabled="!isAdd"
|
|
|
step-strictly
|
|
|
/>
|
|
|
<span class="c-sibling-item far">高</span>
|
|
|
@@ -40,7 +38,6 @@
|
|
|
class="l-flex__auto c-sibling-item"
|
|
|
:min="1"
|
|
|
:max="999999"
|
|
|
- :disabled="!isAdd"
|
|
|
step-strictly
|
|
|
/>
|
|
|
</div>
|
|
|
@@ -50,17 +47,8 @@
|
|
|
v-model="currObj.fpga"
|
|
|
active-color="#13ce66"
|
|
|
inactive-color="#ff4949"
|
|
|
- :disabled="!isAdd"
|
|
|
/>
|
|
|
</div>
|
|
|
- <span class="c-grid-form__label">备注</span>
|
|
|
- <el-input
|
|
|
- v-model.trim="currObj.remark"
|
|
|
- type="textarea"
|
|
|
- maxlength="100"
|
|
|
- :rows="3"
|
|
|
- show-word-limit
|
|
|
- />
|
|
|
</div>
|
|
|
</confirm-dialog>
|
|
|
</schema-table>
|
|
|
@@ -92,19 +80,10 @@ export default {
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
- isAdd: false,
|
|
|
currObj: {},
|
|
|
- proxy: {
|
|
|
- add: addProduct,
|
|
|
- update: updateProduct,
|
|
|
- del: deleteProduct
|
|
|
- },
|
|
|
typeOptions: [],
|
|
|
- fetching: false,
|
|
|
- loaded: false,
|
|
|
productTypeSelectSchema,
|
|
|
schema: {
|
|
|
- condition: { productTypeId: void 0 },
|
|
|
list: this.getProducts,
|
|
|
buttons: [
|
|
|
{ type: 'add', on: this.onAdd }
|
|
|
@@ -113,7 +92,13 @@ export default {
|
|
|
{ key: 'productTypeId', type: 'select', placeholder: '全部类型', ...productTypeSelectSchema }
|
|
|
],
|
|
|
cols: [
|
|
|
- { prop: 'name', label: '配置名称', 'min-width': 60 },
|
|
|
+ { label: '配置名称', render: (data, h) => h('edit-input', {
|
|
|
+ props: {
|
|
|
+ value: `${data.name}`,
|
|
|
+ maxlength: 30
|
|
|
+ },
|
|
|
+ on: { edit: val => this.onEditName(data, val) }
|
|
|
+ }), 'min-width': 120 },
|
|
|
{ prop: 'productTypeName', label: '类型', 'min-width': 60 },
|
|
|
{ prop: 'resolutionRatio', label: '分辨率', 'min-width': 60 },
|
|
|
{ label: '分割器', type: 'tag', render: ({ fpga }) => {
|
|
|
@@ -122,9 +107,7 @@ export default {
|
|
|
label: fpga ? '有' : '无'
|
|
|
}
|
|
|
} },
|
|
|
- { prop: 'remark', label: '备注' },
|
|
|
{ type: 'invoke', render: [
|
|
|
- { label: '编辑', on: this.onEdit },
|
|
|
{ label: '删除', on: this.onDel }
|
|
|
] }
|
|
|
]
|
|
|
@@ -132,18 +115,10 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
- dialogTitle () {
|
|
|
- return this.isAdd ? `新增屏幕配置` : `编辑屏幕配置`
|
|
|
- },
|
|
|
productTypes () {
|
|
|
return this.isAdd ? this.typeOptions : [{ value: this.currObj.productTypeId, label: this.$currObj.productTypeName }]
|
|
|
}
|
|
|
},
|
|
|
- watch: {
|
|
|
- group () {
|
|
|
- this.$refs.table.pageTo(1)
|
|
|
- }
|
|
|
- },
|
|
|
methods: {
|
|
|
getProductTypes (params) {
|
|
|
return getProductTypes({
|
|
|
@@ -158,7 +133,6 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
onAdd () {
|
|
|
- this.isAdd = true
|
|
|
this.productTypeSelectSchema.option = null
|
|
|
this.currObj = {
|
|
|
name: '',
|
|
|
@@ -166,18 +140,28 @@ export default {
|
|
|
wide: 1920,
|
|
|
high: 1080,
|
|
|
fpga: false,
|
|
|
- remark: '',
|
|
|
tenant: this.tenant
|
|
|
}
|
|
|
this.$refs.editDialog.show()
|
|
|
},
|
|
|
- onEdit (product) {
|
|
|
- this.isAdd = false
|
|
|
- const { id, name, productTypeId, productTypeName, high, wide, fpga, remark } = product
|
|
|
- this.productTypeSelectSchema.option = { value: productTypeId, label: productTypeName }
|
|
|
- this.currObj = { id, name, productTypeId, high, wide, fpga, remark }
|
|
|
- this.$currObj = product
|
|
|
- this.$refs.editDialog.show()
|
|
|
+ onEditName (product, { newVal, oldVal }) {
|
|
|
+ if (newVal === oldVal) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!newVal) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请填写配置名称'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ product.name = newVal
|
|
|
+ updateProduct({
|
|
|
+ id: product.id,
|
|
|
+ name: newVal
|
|
|
+ }).catch(() => {
|
|
|
+ product.name = oldVal
|
|
|
+ })
|
|
|
},
|
|
|
onSave (done) {
|
|
|
if (!this.currObj.name) {
|
|
|
@@ -194,23 +178,13 @@ export default {
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
- this.save(done).then(() => {
|
|
|
- if (this.isAdd) {
|
|
|
- this.$refs.table.resetCondition({ productTypeId: this.currObj.productTypeId })
|
|
|
- } else {
|
|
|
- this.$refs.table.pageTo()
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- save (done) {
|
|
|
- if (!this.isAdd && Object.keys(this.currObj).every(key => this.currObj[key] === this.$currObj[key])) {
|
|
|
+ addProduct(this.currObj).then(() => {
|
|
|
done()
|
|
|
- return Promise.reject()
|
|
|
- }
|
|
|
- return (this.isAdd ? addProduct : updateProduct)(this.currObj).then(done)
|
|
|
+ this.$refs.table.resetCondition({ productTypeId: this.currObj.productTypeId })
|
|
|
+ })
|
|
|
},
|
|
|
onDel (product) {
|
|
|
- return deleteProduct(product).then(() => {
|
|
|
+ deleteProduct(product).then(() => {
|
|
|
this.$refs.table.decrease(1)
|
|
|
})
|
|
|
}
|