|
|
@@ -0,0 +1,215 @@
|
|
|
+<template>
|
|
|
+ <wrapper
|
|
|
+ fill
|
|
|
+ margin
|
|
|
+ padding
|
|
|
+ background
|
|
|
+ >
|
|
|
+ <schema-table
|
|
|
+ ref="table"
|
|
|
+ :schema="schema"
|
|
|
+ />
|
|
|
+ <confirm-dialog
|
|
|
+ ref="editDialog"
|
|
|
+ :title="dialogTitle"
|
|
|
+ @confirm="onConfirm"
|
|
|
+ >
|
|
|
+ <div class="c-grid-form u-align-self--center">
|
|
|
+ <span class="c-grid-form__label u-required">厂商</span>
|
|
|
+ <schema-select
|
|
|
+ v-model="screen.manufacturerKey"
|
|
|
+ class="u-width"
|
|
|
+ placeholder="请选择厂商"
|
|
|
+ :schema="manufacturerSelectSchema"
|
|
|
+ />
|
|
|
+ <span class="c-grid-form__label u-required">型号</span>
|
|
|
+ <el-input
|
|
|
+ v-model.trim="screen.type"
|
|
|
+ placeholder="最多50个字符"
|
|
|
+ maxlength="50"
|
|
|
+ clearable
|
|
|
+ />
|
|
|
+ <span class="c-grid-form__label u-required">间距</span>
|
|
|
+ <div class="l-flex--row c-grid-form__option">
|
|
|
+ <el-input
|
|
|
+ v-model.trim="screen.pitch"
|
|
|
+ class="c-sibling-item u-width--xs"
|
|
|
+ placeholder="例:3.6"
|
|
|
+ maxlength="10"
|
|
|
+ clearable
|
|
|
+ />
|
|
|
+ <span class="c-sibling-item u-font-size--sm">mm</span>
|
|
|
+ </div>
|
|
|
+ <span class="c-grid-form__label">点对点</span>
|
|
|
+ <div class="l-flex--row c-grid-form__option">
|
|
|
+ <el-switch
|
|
|
+ v-model="screen.dot"
|
|
|
+ active-color="#13ce66"
|
|
|
+ inactive-color="#ff4949"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <span class="c-grid-form__label u-required">质保到期时间</span>
|
|
|
+ <el-date-picker
|
|
|
+ v-model="screen.qualificationDate"
|
|
|
+ class="u-width--sm"
|
|
|
+ type="date"
|
|
|
+ placeholder="请选择质保到期时间"
|
|
|
+ value-format="yyyy-MM-dd"
|
|
|
+ :clearable="false"
|
|
|
+ />
|
|
|
+ <span class="c-grid-form__label u-required">位置</span>
|
|
|
+ <el-input
|
|
|
+ v-model.trim="screen.remark"
|
|
|
+ type="textarea"
|
|
|
+ placeholder="最多100个字符"
|
|
|
+ maxlength="100"
|
|
|
+ :rows="4"
|
|
|
+ resize="none"
|
|
|
+ show-word-limit
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </confirm-dialog>
|
|
|
+ </wrapper>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import {
|
|
|
+ getScreenManufacturers,
|
|
|
+ getScreens,
|
|
|
+ addScreen,
|
|
|
+ updateScreen,
|
|
|
+ deleteScreen
|
|
|
+} from '@/api/external'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'ScreenList',
|
|
|
+ data () {
|
|
|
+ const manufacturerSelectSchema = {
|
|
|
+ remote: getScreenManufacturers,
|
|
|
+ value: 'manufacturerKey',
|
|
|
+ label: 'manufacturerName'
|
|
|
+ }
|
|
|
+
|
|
|
+ return {
|
|
|
+ screen: {},
|
|
|
+ manufacturerSelectSchema,
|
|
|
+ schema: {
|
|
|
+ condition: { manufacturerKey: void 0 },
|
|
|
+ list: getScreens,
|
|
|
+ buttons: [
|
|
|
+ { type: 'add', on: this.onAdd }
|
|
|
+ ],
|
|
|
+ filters: [
|
|
|
+ { key: 'manufacturerKey', type: 'select', placeholder: '厂商', ...manufacturerSelectSchema }
|
|
|
+ ],
|
|
|
+ cols: [
|
|
|
+ { prop: 'manufacturerName', label: '厂商', 'min-width': 60 },
|
|
|
+ { prop: 'type', label: '型号' },
|
|
|
+ { prop: 'pitch', label: '间距(mm)' },
|
|
|
+ { label: '点对点', type: 'tag', render: ({ dot }) => {
|
|
|
+ return {
|
|
|
+ type: dot ? 'success' : 'danger',
|
|
|
+ label: dot ? '是' : '否'
|
|
|
+ }
|
|
|
+ } },
|
|
|
+ { prop: 'qualificationDate', label: '质保到期时间', 'align': 'center' },
|
|
|
+ { prop: 'remark', label: '位置', 'min-width': 160, 'align': 'right' },
|
|
|
+ { type: 'invoke', render: [
|
|
|
+ { label: '删除', on: this.onDel }
|
|
|
+ ] }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ dialogTitle () {
|
|
|
+ return this.screen.id ? '编辑屏幕' : '新增屏幕'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onAdd () {
|
|
|
+ this.screen = {
|
|
|
+ manufacturerKey: '',
|
|
|
+ type: '',
|
|
|
+ pitch: '',
|
|
|
+ dot: false,
|
|
|
+ qualificationDate: '',
|
|
|
+ remark: ''
|
|
|
+ }
|
|
|
+ this.$refs.editDialog.show()
|
|
|
+ },
|
|
|
+ onEdit ({ id, manufacturerKey, manufacturerName, name, type }) {
|
|
|
+ this.manufacturerSelectSchema.option = { value: manufacturerKey, label: manufacturerName }
|
|
|
+ this.screen = { id, manufacturerKey, name, type }
|
|
|
+ this.$refs.editDialog.show()
|
|
|
+ },
|
|
|
+ onConfirm (done) {
|
|
|
+ const screen = this.screen
|
|
|
+ if (!screen.manufacturerKey) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请选择厂商'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!screen.type) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请填写屏幕型号'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!screen.pitch) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请填写屏幕间距'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!/^\d+(\.\d+)?$/.test(screen.pitch)) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '屏幕间距格式错误'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!screen.qualificationDate) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请填写屏幕质保到期时间'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!screen.remark) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请填写屏幕位置'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (screen.id) {
|
|
|
+ this.onConfirmEdit(screen, done)
|
|
|
+ } else {
|
|
|
+ this.onConfirmAdd(screen, done)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onConfirmAdd (screen, done) {
|
|
|
+ addScreen(screen).then(() => {
|
|
|
+ done()
|
|
|
+ this.$refs.table.resetCondition({ manufacturerKey: this.screen.manufacturerKey })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onConfirmEdit (screen, done) {
|
|
|
+ updateScreen(screen).then(() => {
|
|
|
+ done()
|
|
|
+ this.$refs.table.pageTo()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onDel (item) {
|
|
|
+ deleteScreen(item).then(() => {
|
|
|
+ this.$refs.table.decrease(1)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|