From aeebddd7eca7d1432524943c0ce7df3e33f35705 Mon Sep 17 00:00:00 2001
From: Houjie <714924425@qq.com>
Date: 星期五, 05 九月 2025 09:15:14 +0800
Subject: [PATCH] 打印机配置页面

---
 src/views/base/modules/printerConfig/PrinterConfigModel.vue |  249 ++++++++++++++++++++++++
 src/views/base/PrinterConfigList.vue                        |  328 ++++++++++++++++++++++++++++++++
 2 files changed, 577 insertions(+), 0 deletions(-)

diff --git a/src/views/base/PrinterConfigList.vue b/src/views/base/PrinterConfigList.vue
new file mode 100644
index 0000000..932cc76
--- /dev/null
+++ b/src/views/base/PrinterConfigList.vue
@@ -0,0 +1,328 @@
+<template>
+  <a-card
+    :bordered="false"
+  >
+    <!-- 鏌ヨ鍖哄煙 -->
+    <div class="table-page-search-wrapper">
+      <a-form
+        layout="inline"
+        @keyup.enter.native="searchQuery"
+      >
+        <a-row :gutter="30">
+
+          <a-col :xl="6" :lg="7" :md="8" :sm="24">
+            <a-form-item label="鎵撳嵃鏈篒P">
+              <j-input
+                placeholder="璇疯緭鍏ユ墦鍗版満IP妫�绱�"
+                v-model="queryParam.printerIp "
+              ></j-input>
+            </a-form-item>
+          </a-col>
+          <a-col :xl="6" :lg="7" :md="8" :sm="24">
+            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
+              <a-button type="primary" @click="searchQuery" icon="search">鏌ヨ</a-button>
+              <a-button type="info" @click="searchReset" icon="reload" style="margin-left: 8px">閲嶇疆</a-button>
+            </span>
+          </a-col>
+        </a-row>
+      </a-form>
+    </div>
+
+    <!-- 鎿嶄綔鎸夐挳鍖哄煙 -->
+    <div class="table-operator">
+      <a-button
+        @click="handleAdd"
+        type="primary"
+        icon="plus"
+      >鏂板
+      </a-button>
+    </div>
+
+    <!-- table鍖哄煙-begin -->
+    <div>
+      <a-table
+        ref="table"
+        size="middle"
+        bordered
+        rowKey="id"
+        filterMultiple="filterMultiple"
+        :columns="columns"
+        :rowClassName="tableRowClass"
+        :dataSource="dataSource"
+        :pagination="ipagination"
+        :loading="loading"
+        @change="handleTableChange"
+      >
+        <!--鐘舵�佹爮涓�у睍绀�-->
+        <span
+          slot="status"
+          slot-scope="text,record"
+        >
+          <a-badge
+            v-if="record.printerStatus==1"
+            status="success"
+          />
+          <span
+            v-if="record.printerStatus==1"
+            class="success"
+          >鍚敤</span>
+          <a-badge
+            v-if="record.printerStatus==0"
+            status="error"
+          />
+          <span
+            v-if="record.printerStatus==0"
+            class="error"
+          >绂佺敤</span>
+        </span>
+        <span
+          slot="action"
+          slot-scope="text, record"
+        >
+          <a
+            href="javascript:;"
+            @click="handleEdit(record)"
+          >缂栬緫</a>
+
+          <a-divider type="vertical" />
+          <a-dropdown>
+            <a class="ant-dropdown-link">鏇村
+              <a-icon type="down" />
+            </a>
+            <a-menu slot="overlay">
+              <a-menu-item>
+                <a @click="handleDetail(record)">璇︽儏</a>
+              </a-menu-item>
+               <a-menu-item v-if="record.printerStatus == 0">
+                <a-popconfirm
+                  title="纭畾鍚敤鍚�?"
+                  @confirm="() => handleActive(record.id)"
+                >
+                  <a>鍚敤</a>
+                </a-popconfirm>
+              </a-menu-item>
+              <a-menu-item v-if="record.printerStatus == 1">
+                <a-popconfirm
+                  title="纭畾绂佺敤鍚�?"
+                  @confirm="() => handleActive(record.id)"
+                >
+                  <a>绂佺敤</a>
+                </a-popconfirm>
+              </a-menu-item>
+              <a-menu-item>
+                <a-popconfirm
+                  title="纭畾鍒犻櫎鍚�?"
+                  @confirm="() => handleDelete(record.id)"
+                >
+                  <a>鍒犻櫎</a>
+                </a-popconfirm>
+
+              </a-menu-item>
+
+            </a-menu>
+          </a-dropdown>
+        </span>
+
+      </a-table>
+    </div>
+    <!-- table鍖哄煙-end -->
+
+    <!-- 琛ㄥ崟鍖哄煙 -->
+    <printer-config-model
+      ref="modalForm"
+      @ok="modalFormOk"
+    ></printer-config-model>
+  </a-card>
+</template>
+
+<script>
+//鎸夐渶寮曞叆 缁勪欢
+import PrinterConfigModel from './modules/printerConfig/PrinterConfigModel'
+
+import { getAction, requestPut } from '@/api/manage'
+import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+import JEllipsis from '@/components/jeecg/JEllipsis'
+import JInput from '@/components/jeecg/JInput'
+
+export default {
+  name: 'PrinterConfigList',
+  mixins: [JeecgListMixin],
+  components: {
+    PrinterConfigModel,
+    JEllipsis,
+    JInput
+  },
+  data() {
+    return {
+      dataSource: [],
+      /* 鍒嗛〉鍙傛暟 */
+      ipagination: {
+        current: 1,
+        pageSize: 10,
+        pageSizeOptions: ['10', '20', '30'],
+        showTotal: (total, range) => {
+          return range[0] + '-' + range[1] + ' 鍏�' + total + '鏉�'
+        },
+        showQuickJumper: true,
+        showSizeChanger: true,
+        total: 0
+      },
+      /* 鎺掑簭鍙傛暟 */
+      isorter:{
+        column: 'printerIp',
+        order: 'asc',
+      },
+      // 琛ㄥご
+      columns: [
+        {
+          title: '#',
+          dataIndex: '',
+          key: 'rowIndex',
+          width: 60,
+          align: 'center',
+          customRender: function(t, r, index) {
+            return parseInt(index) + 1
+          }
+        },
+        {
+          title: '鎵撳嵃鏈篒P',
+          align: 'center',
+          dataIndex: 'printerIp'
+        },
+        {
+          title: '鎵撳嵃鏈哄悕绉�',
+          align: 'center',
+          dataIndex: 'printerName'
+        },
+        {
+          title: '鎵撳嵃鏈虹鍙�',
+          align: 'center',
+          dataIndex: 'portNumber'
+        },
+        {
+          title: '鎵撳嵃鏈哄瀷鍙�',
+          align: 'center',
+          dataIndex: 'printerModel'
+        },
+        {
+          width: 100,
+          title: '鐘舵��',
+          align: 'center',
+          scopedSlots: {
+            customRender: 'status'
+          },
+          dataIndex: 'printerStatus'
+        },
+        {
+          width: 150,
+          title: '鎿嶄綔',
+          dataIndex: 'action',
+          align: 'center',
+          scopedSlots: { customRender: 'action' }
+        }
+      ],
+      url: {
+        list: '/base/printerConfig/list',
+        delete: '/base/printerConfig/delete',
+        active: '/base/printerConfig/active'
+      }
+    }
+  },
+  mounted() {
+
+  },
+  methods: {
+    loadData(arg) {
+      if (arg === 1) {
+        this.ipagination.current = 1
+      }
+      var params = this.getQueryParams()//鏌ヨ鏉′欢
+      this.loading = true
+      getAction(this.url.list, params).then((res) => {
+        if (res.success) {
+          this.dataSource = res.result.records
+          this.ipagination.total = res.result.total
+        }
+        if (res.code === 510) {
+          this.$message.warning(res.message)
+        }
+        this.loading = false
+      })
+    },
+    //绂佺敤鐘舵�佹牱寮�
+    tableRowClass(record, index) {
+      if (record.printerStatus != '1') {
+        return 'frozenRowClass'
+      }
+      return ''
+    },
+    //鍚敤绂佺敤
+    handleActive(id) {
+      if (!this.url.active) {
+        this.$message.error('璇疯缃畊rl.active!')
+        return
+      }
+      let that = this
+      requestPut(that.url.active, {}, { id: id }).then((res) => {
+        if (res.success) {
+          that.$message.success(res.message)
+          that.loadData()
+        } else {
+          that.$message.warning(res.message)
+        }
+      })
+    }
+  }
+
+}
+</script>
+<style lang="less" scoped>
+@import '~@assets/less/common.less';
+
+.frozenRowClass {
+  color: #c9c9c9;
+}
+
+.success {
+  color: green;
+}
+
+.error {
+  color: red;
+}
+
+.fontweight {
+  font-weight: bold;
+}
+
+.ant-card-body .table-operator {
+  margin-bottom: 18px;
+}
+
+.ant-table-tbody .ant-table-row td {
+  padding-top: 15px;
+  padding-bottom: 15px;
+}
+
+.anty-row-operator button {
+  margin: 0 5px;
+}
+
+/deep/ .ant-btn-danger {
+  background-color: #ffffff;
+}
+
+.ant-modal-cust-warp {
+  height: 100%;
+}
+
+.ant-modal-cust-warp .ant-modal-body {
+  height: calc(100% - 110px) !important;
+  overflow-y: auto;
+}
+
+.ant-modal-cust-warp .ant-modal-content {
+  height: 90% !important;
+  overflow-y: hidden;
+}
+</style>
\ No newline at end of file
diff --git a/src/views/base/modules/printerConfig/PrinterConfigModel.vue b/src/views/base/modules/printerConfig/PrinterConfigModel.vue
new file mode 100644
index 0000000..e4e6f47
--- /dev/null
+++ b/src/views/base/modules/printerConfig/PrinterConfigModel.vue
@@ -0,0 +1,249 @@
+<template>
+  <a-modal
+    :title="title"
+    :width="800"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    :maskClosable="false"
+    :okButtonProps="{ props: {disabled: disableSubmit} }"
+    @ok="handleOk"
+    @cancel="handleCancel"
+    cancelText="鍏抽棴"
+  >
+    <a-spin :spinning="confirmLoading">
+      <a-form :form="form">
+
+        <a-row :gutter="24">
+          <a-col :span="24">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="鎵撳嵃鏈篒P"
+            >
+              <a-input
+                :disabled="disableSubmit"
+                allow-clear
+                placeholder="璇疯緭鍏ユ墦鍗版満IP"
+                v-decorator="['printerIp', validatorRules.printerIp]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row :gutter="24">
+          <a-col :span="24">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="鎵撳嵃鏈哄悕绉�"
+            >
+              <a-input
+                :disabled="disableSubmit"
+                allow-clear
+                placeholder="璇疯緭鍏ユ墦鍗版満绔彛"
+                v-decorator="['printerName', validatorRules.printerName]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row :gutter="24">
+          <a-col :span="24">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="鎵撳嵃鏈虹鍙�"
+            >
+              <a-input
+                :disabled="disableSubmit"
+                allow-clear
+                placeholder="璇疯緭鍏ユ墦鍗版満绔彛"
+                v-decorator="['portNumber', validatorRules.portNumber]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+
+        <a-row :gutter="24">
+          <a-col :span="24">
+            <a-form-item
+              :labelCol="labelCol"
+              :wrapperCol="wrapperCol"
+              label="鎵撳嵃鏈哄瀷鍙�"
+            >
+              <a-input
+                :disabled="disableSubmit"
+                allow-clear
+                placeholder="璇疯緭鍏ユ墦鍗版満鍨嬪彿"
+                v-decorator="['printerModel', validatorRules.printerModel]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+      </a-form>
+    </a-spin>
+  </a-modal>
+</template>
+
+<script>
+import { httpAction } from '@/api/manage'
+import pick from 'lodash.pick'
+import { duplicateCheck } from '@/api/api' //閲嶅鏍¢獙
+
+export default {
+  name: 'PrinterConfigModel',
+  components: {},
+  data() {
+    return {
+      title: '鎿嶄綔',
+      visible: false,
+      disableSubmit: false,
+      model: {},
+      treeData: [],
+      labelCol: {
+        xs: { span: 24 },
+        sm: { span: 5 }
+      },
+      wrapperCol: {
+        xs: { span: 24 },
+        sm: { span: 16 }
+      },
+
+      confirmLoading: false,
+      form: this.$form.createForm(this),
+      validatorRules: {
+        printerIp: {
+          rules: [
+            { required: true, message: '璇疯緭鍏ユ墦鍗版満IP' },
+            { min: 2, max: 30, message: '闀垮害鍦� 2 鍒� 30 涓瓧绗�', trigger: 'blur' },
+          ]
+        },
+        printerName: {
+          rules: [
+            { required: true, message: '璇疯緭鍏ユ墦鍗版満鍚嶇О' },
+            { min: 2, max: 30, message: '闀垮害鍦� 2 鍒� 30 涓瓧绗�', trigger: 'blur' },
+          ]
+        },
+        portNumber: {
+          rules: [
+            { required: true, message: '璇疯緭鍏ユ墦鍗版満绔彛' },
+            { min: 0, max: 64, message: '闀垮害涓嶈秴杩� 64 涓瓧绗�', trigger: 'blur' },
+            { validator: this.validateName }
+          ]
+        },
+
+        printerModel: {
+          rules: [
+            { required: true, message: '璇疯緭鍏ユ墦鍗版満鍨嬪彿' },
+            { min: 0, max: 64, message: '闀垮害涓嶈秴杩� 64 涓瓧绗�', trigger: 'blur' }
+          ]
+        }
+      },
+      url: {
+        add: '/base/printerConfig/add',
+        edit: '/base/printerConfig/edit'
+      },
+      nextFactoryOptions: []
+    }
+  },
+
+
+  created() {
+  },
+  methods: {
+    add() {
+      this.edit({})
+    },
+    edit(record) {
+      this.form.resetFields()
+      this.model = Object.assign({}, record)
+      this.warehouseId = record.id
+      this.visible = true
+      this.$nextTick(() => {
+        this.form.setFieldsValue(
+          pick(this.model, 'printerIp','printerName', 'portNumber', 'printerModel')
+        )
+      })
+    },
+    close() {
+      this.$emit('close')
+      this.visible = false
+    },
+    handleOk() {
+      console.log('琛ㄥ崟鍊�:', this.form.getFieldsValue())
+      const that = this
+      // 瑙﹀彂琛ㄥ崟楠岃瘉
+      this.form.validateFields((err, values) => {
+        if (!err) {
+          that.confirmLoading = true
+          let httpurl = ''
+          let method = ''
+          if (!this.model.id) {
+            httpurl += this.url.add
+            method = 'post'
+          } else {
+            httpurl += this.url.edit
+            method = 'put'
+          }
+          let formData = Object.assign(this.model, values)
+          httpAction(httpurl, formData, method).then((res) => {
+            if (res.success) {
+              that.$message.success(res.message)
+              that.$emit('ok')
+            } else {
+              that.$message.warning(res.message)
+            }
+          }).finally(() => {
+            that.confirmLoading = false
+            that.close()
+          })
+        }
+      })
+    },
+    handleCancel() {
+      this.close()
+    },
+
+    //楠岃瘉 鍚嶇О
+    validateName(rule, value, callback) {
+      var params = {
+        tableName: 'base_printer_config',
+        fieldName: 'port_number',
+        fieldVal: value,
+        //鏁版嵁搴撲腑瀛樺湪瀛楁del_flag骞朵娇鐢ㄨ瀛楁浣滀负鏈垹闄ょ瓥鐣ワ紝鐪熷垹闄わ細false 鍋囧垹闄わ細true
+        delFlag: 'true'
+      }
+      duplicateCheck(params).then((res) => {
+        if (res.success) {
+          callback()
+        } else {
+          callback('鎵撳嵃鏈虹鍙e凡瀛樺湪!')
+        }
+      })
+    },
+    // 鍏抽棴寮圭獥鏃舵竻闄よ〃鍗曟牎楠�
+    removeValidate() {
+      if (this.$refs.form) this.$refs.form.clearValidate()
+    }
+  }
+}
+</script>
+
+<style scoped>
+.ant-btn {
+  padding: 0 10px;
+  margin-left: 3px;
+}
+
+.ant-form-item-control {
+  line-height: 0px;
+}
+
+/** 涓昏〃鍗曡闂磋窛 */
+.ant-form .ant-form-item {
+  margin-bottom: 10px;
+}
+
+/** Tab椤甸潰琛岄棿璺� */
+.ant-tabs-content .ant-form-item {
+  margin-bottom: 0px;
+}
+</style>
\ No newline at end of file

--
Gitblit v1.9.3