|
@@ -0,0 +1,263 @@
|
|
|
|
|
+<!--
|
|
|
|
|
+ * @Descripttion: 用户选择器
|
|
|
|
|
+ * @version: 1.0
|
|
|
|
|
+ * @Author: Zory
|
|
|
|
|
+ * @Date: 2024年1月10日21:46:29
|
|
|
|
|
+-->
|
|
|
|
|
+<template>
|
|
|
|
|
+ <el-dialog :title="titleMap[mode]" v-model="visible" :width="800" destroy-on-close @closed="$emit('closed')">
|
|
|
|
|
+ <div class="main">
|
|
|
|
|
+ <div class="main-left">
|
|
|
|
|
+ <div class="main-top">
|
|
|
|
|
+ <el-form class="lv-form-inline" ref="searchForm" :model="searchKey" label-position="right">
|
|
|
|
|
+ <el-row :gutter="10">
|
|
|
|
|
+ <el-col :span="18" :xs="12">
|
|
|
|
|
+ <el-form-item label=" " prop="name">
|
|
|
|
|
+ <el-input v-model="searchKey.name" placeholder="请输入名称" clearable
|
|
|
|
|
+ :style="{width: '100%'}"></el-input>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ <el-col :span="6" :xs="12">
|
|
|
|
|
+ <el-form-item>
|
|
|
|
|
+ <div class="search-btn">
|
|
|
|
|
+ <el-button type="primary" @click="searchForm">搜索</el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ </el-row>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="main-body-wrap" v-if="!multiple">
|
|
|
|
|
+ <scTable ref="table" :apiObj="list.apiObj" :hideSetting="true" paginationLayout="total, prev, pager, next" :params="searchKey" @current-change="handleCurrentChange" highlight-current-row :row-key="getRowKeys" @sortChange="sortChange">
|
|
|
|
|
+ <el-table-column width="50" fixed="left">
|
|
|
|
|
+ <div class="checkbox"></div>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="序列号" prop="sn" width="220" fixed="left">
|
|
|
|
|
+ <template #default="scope">
|
|
|
|
|
+ <span v-if="scope.row.sn">{{ scope.row.sn }}</span>
|
|
|
|
|
+ <span class="status-danger" v-else>未设置</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="打印机名称" prop="name" width="220">
|
|
|
|
|
+ <template #default="scope">
|
|
|
|
|
+ <span v-if="scope.row.name">{{ scope.row.name }}</span>
|
|
|
|
|
+ <span class="status-danger" v-else>未设置</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="设备状态" prop="device_state" width="160">
|
|
|
|
|
+ <template #default="scope">
|
|
|
|
|
+ <div class="status-success" v-if="scope.row.device_state==0"><sc-status-indicator type="success"></sc-status-indicator> 正常</div>
|
|
|
|
|
+ <div class="status-danger" v-if="scope.row.device_state==1"><sc-status-indicator type="danger"></sc-status-indicator> 开盖</div>
|
|
|
|
|
+ <div class="status-info" v-if="scope.row.device_state==2"><sc-status-indicator type="info"></sc-status-indicator> 粘纸</div>
|
|
|
|
|
+ <div class="status-info" v-if="scope.row.device_state==3"><sc-status-indicator type="info"></sc-status-indicator> 缺纸</div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="在线状态" prop="status" width="160">
|
|
|
|
|
+ <template #default="scope">
|
|
|
|
|
+ <div class="status-success" v-if="scope.row.online=='ONLINE'"><sc-status-indicator type="success"></sc-status-indicator> 正常</div>
|
|
|
|
|
+ <div class="status-danger" v-if="scope.row.online=='OFFLINE'"><sc-status-indicator type="danger"></sc-status-indicator> 离线</div>
|
|
|
|
|
+ <div class="status-info" v-if="scope.row.online=='UNACTIVE'"><sc-status-indicator type="info"></sc-status-indicator> 未激活</div>
|
|
|
|
|
+ <div class="status-info" v-if="scope.row.online=='DISABLE'"><sc-status-indicator type="info"></sc-status-indicator> 已禁用</div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="创建时间" prop="create_at" width="180"></el-table-column>
|
|
|
|
|
+ </scTable>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="main-body-wrap" v-else>
|
|
|
|
|
+ <scTable ref="table" :apiObj="list.apiObj" :hideSetting="true" paginationLayout="total, prev, pager, next" :params="searchKey" @selectionChange="selectionChange" row-key="id" @sortChange="sortChange">
|
|
|
|
|
+ <el-table-column type="selection" width="50" fixed="left"></el-table-column>
|
|
|
|
|
+ <el-table-column label="序列号" prop="sn" width="220" fixed="left">
|
|
|
|
|
+ <template #default="scope">
|
|
|
|
|
+ <span v-if="scope.row.sn">{{ scope.row.sn }}</span>
|
|
|
|
|
+ <span class="status-danger" v-else>未设置</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="打印机名称" prop="name" width="220">
|
|
|
|
|
+ <template #default="scope">
|
|
|
|
|
+ <span v-if="scope.row.name">{{ scope.row.name }}</span>
|
|
|
|
|
+ <span class="status-danger" v-else>未设置</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="设备状态" prop="device_state" width="160">
|
|
|
|
|
+ <template #default="scope">
|
|
|
|
|
+ <div class="status-success" v-if="scope.row.device_state==0"><sc-status-indicator type="success"></sc-status-indicator> 正常</div>
|
|
|
|
|
+ <div class="status-danger" v-if="scope.row.device_state==1"><sc-status-indicator type="danger"></sc-status-indicator> 开盖</div>
|
|
|
|
|
+ <div class="status-info" v-if="scope.row.device_state==2"><sc-status-indicator type="info"></sc-status-indicator> 粘纸</div>
|
|
|
|
|
+ <div class="status-info" v-if="scope.row.device_state==3"><sc-status-indicator type="info"></sc-status-indicator> 缺纸</div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="在线状态" prop="status" width="160">
|
|
|
|
|
+ <template #default="scope">
|
|
|
|
|
+ <div class="status-success" v-if="scope.row.online=='ONLINE'"><sc-status-indicator type="success"></sc-status-indicator> 正常</div>
|
|
|
|
|
+ <div class="status-danger" v-if="scope.row.online=='OFFLINE'"><sc-status-indicator type="danger"></sc-status-indicator> 离线</div>
|
|
|
|
|
+ <div class="status-info" v-if="scope.row.online=='UNACTIVE'"><sc-status-indicator type="info"></sc-status-indicator> 未激活</div>
|
|
|
|
|
+ <div class="status-info" v-if="scope.row.online=='DISABLE'"><sc-status-indicator type="info"></sc-status-indicator> 已禁用</div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="创建时间" prop="create_at" width="180"></el-table-column>
|
|
|
|
|
+ </scTable>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <template #footer>
|
|
|
|
|
+ <el-button @click="visible=false" >取 消</el-button>
|
|
|
|
|
+ <el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="submit()">确 定</el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-dialog>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script>
|
|
|
|
|
+export default{
|
|
|
|
|
+ emits: ['success', 'closed'],
|
|
|
|
|
+ props: {
|
|
|
|
|
+ multiple: { type: Boolean, default: false },
|
|
|
|
|
+ },
|
|
|
|
|
+ data(){
|
|
|
|
|
+ return {
|
|
|
|
|
+ loading: false,
|
|
|
|
|
+ mode:"add",
|
|
|
|
|
+ titleMap:{
|
|
|
|
|
+ add:"选择打印机",
|
|
|
|
|
+ edit:"选择打印机"
|
|
|
|
|
+ },
|
|
|
|
|
+ list: {
|
|
|
|
|
+ apiObj: this.$API.merPrint.list
|
|
|
|
|
+ },
|
|
|
|
|
+ visible: false,
|
|
|
|
|
+ isSaveing: false,
|
|
|
|
|
+ formData:{},
|
|
|
|
|
+ searchKey:{},
|
|
|
|
|
+ selectData:[]
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ methods:{
|
|
|
|
|
+ sortChange(event){
|
|
|
|
|
+ if (event.order) {
|
|
|
|
|
+ var data = {
|
|
|
|
|
+ "field":event.prop,
|
|
|
|
|
+ "order":event.order
|
|
|
|
|
+ }
|
|
|
|
|
+ this.$refs.table.upData(data)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$refs.table.reload(this.searchKey)
|
|
|
|
|
+ }
|
|
|
|
|
+ return ;
|
|
|
|
|
+ },
|
|
|
|
|
+ submit(){
|
|
|
|
|
+ if (this.selectData.length == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ return this.$message.error("请选择数据");
|
|
|
|
|
+ }
|
|
|
|
|
+ this.isSaveing = false;
|
|
|
|
|
+ this.visible = false;
|
|
|
|
|
+ if (this.multiple){
|
|
|
|
|
+ this.$emit('success', this.selectData);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$emit('success', this.selectData[0]);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ getRowKeys(data){
|
|
|
|
|
+ return data.id;
|
|
|
|
|
+ },
|
|
|
|
|
+ clearAll(){
|
|
|
|
|
+ this.selectData = [];
|
|
|
|
|
+ },
|
|
|
|
|
+ removeUser(index,name){
|
|
|
|
|
+ this.selectData.splice(index, 1);
|
|
|
|
|
+ console.log(name)
|
|
|
|
|
+ },
|
|
|
|
|
+ handleCurrentChange(data){
|
|
|
|
|
+ this.selectData = [data];
|
|
|
|
|
+ },
|
|
|
|
|
+ selectionChange(data){
|
|
|
|
|
+ this.selectData = data;
|
|
|
|
|
+ },
|
|
|
|
|
+ searchForm(){
|
|
|
|
|
+ this.$refs.table.upData(this.searchKey)
|
|
|
|
|
+ },
|
|
|
|
|
+ fristName(name){
|
|
|
|
|
+ return name.substring(0,1);
|
|
|
|
|
+ },
|
|
|
|
|
+ open(mode = 'add'){
|
|
|
|
|
+ this.mode = mode;
|
|
|
|
|
+ this.visible = true;
|
|
|
|
|
+ return this
|
|
|
|
|
+ },
|
|
|
|
|
+ //表单注入数据
|
|
|
|
|
+ setData(data){
|
|
|
|
|
+ this.formData = data;
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
|
+.main{
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ border: 1px solid #dfe1e6;
|
|
|
|
|
+}
|
|
|
|
|
+.main-left{
|
|
|
|
|
+ overflow: hidden;
|
|
|
|
|
+ flex: 1;
|
|
|
|
|
+ .main-body-wrap{
|
|
|
|
|
+ position: relative;
|
|
|
|
|
+ height: 380px;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+.main-top{
|
|
|
|
|
+ position: relative;
|
|
|
|
|
+ padding: 10px 0;
|
|
|
|
|
+ border-bottom: 1px solid #dfe1e6;
|
|
|
|
|
+ &.is-right{
|
|
|
|
|
+ height:53px;
|
|
|
|
|
+ display:flex;
|
|
|
|
|
+ align-items:center;
|
|
|
|
|
+ padding:0 10px;
|
|
|
|
|
+ justify-content:space-between;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+.main-body.is-right{
|
|
|
|
|
+ padding: 8px 16px;
|
|
|
|
|
+ overflow-y: auto;
|
|
|
|
|
+ position: relative;
|
|
|
|
|
+ height: calc(100% - 53px);
|
|
|
|
|
+ max-height: 380px;
|
|
|
|
|
+}
|
|
|
|
|
+.mx-1{
|
|
|
|
|
+ margin: 0 0.5rem 0.5rem 0;
|
|
|
|
|
+}
|
|
|
|
|
+.main-right{
|
|
|
|
|
+ flex: 0.4;
|
|
|
|
|
+}
|
|
|
|
|
+.el-form-item--default{
|
|
|
|
|
+ margin-bottom: 0;
|
|
|
|
|
+}
|
|
|
|
|
+.checkbox{
|
|
|
|
|
+ border:1px solid #dfe1e6;
|
|
|
|
|
+ width: 14px;
|
|
|
|
|
+ height: 14px;
|
|
|
|
|
+ border-radius: 2px;
|
|
|
|
|
+ background-color: #fff;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ position:relative
|
|
|
|
|
+}
|
|
|
|
|
+.current-row .checkbox{
|
|
|
|
|
+ background-color: var(--el-color-primary);
|
|
|
|
|
+ border-color: var(--el-color-primary);
|
|
|
|
|
+}
|
|
|
|
|
+.current-row .checkbox:after{
|
|
|
|
|
+ transform: rotate(45deg) scaleY(1);
|
|
|
|
|
+ box-sizing: content-box;
|
|
|
|
|
+ content: "";
|
|
|
|
|
+ border: 1px solid #fff;
|
|
|
|
|
+ border-left: 0;
|
|
|
|
|
+ border-top: 0;
|
|
|
|
|
+ height: 7px;
|
|
|
|
|
+ left: 4px;
|
|
|
|
|
+ position: absolute;
|
|
|
|
|
+ top: 1px;
|
|
|
|
|
+ width: 3px;
|
|
|
|
|
+ transition: transform .15s ease-in 50ms;
|
|
|
|
|
+ transform-origin: center;
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|