liuyanpeng 4 месяцев назад
Родитель
Сommit
b1aaeca078

+ 2 - 2
package.json

@@ -20,7 +20,7 @@
     "client-base-v5": "1.0.8",
     "client-dic-v3": "^3.0.52",
     "client-eam-v5": "1.0.2",
-    "client-role-v3": "^3.0.26",
+    "client-role-v3": "3.0.26-cf.1",
     "client-sensor-v3": "^1.0.4",
     "client-wms-cf": "1.0.0-2",
     "client-finance-v3": "^0.0.4",
@@ -28,7 +28,7 @@
     "dingtalk-jsapi": "^2.8.33",
     "js-cookie": "^2.2.1",
     "lodash": "^4.17.21",
-    "pc-component-v3": "2.0.4",
+    "pc-component-v3": "2.0.5",
     "qrcode": "^1.5.3",
     "select2": "^4.0.13",
     "select2-bootstrap-theme": "^0.1.0-beta.10",

+ 47 - 10
src/custom/common/CommonTable.vue

@@ -2,16 +2,19 @@
   <div class="tablePaganations">
     <!-- <a-config-provider :locale="locale"> -->
     <a-table id="commonTable" class="ant-table-striped" bordered size="small" height="1000px" :loading="isLoading"
-      :data-source="dataSource" :columns="columns" :row-key="(record) => record.id" :scroll="{ y: yScroll }"
+      :data-source="dataSource" :columns="columns" :row-key="(record) => record.id" :scroll="{ y: yScroll, x: xScroll }"
       :pagination="havePage ? pagination : false" :row-class-name="(_record, index) => (index % 2 === 1 ? 'table-striped' : null)
         " :row-selection="isSelect
           ? {
+            type: selectType === 'radio' ? 'radio' : 'checkbox',
             selectedRowKeys: state.selectedRowKeys,
             onSelect: selectEvent,
             onSelectAll: selectAllEvent,
+            hideSelectAll: hideSelectAll,
           }
           : null
-        " @change="tableChange" @resize-column="handleResizeColumn">
+          " :custom-row="isCustomRowClick ? customRowClick : null" @change="tableChange"
+      @resize-column="handleResizeColumn">
       <template v-for="(item, index) in renderArr" #[item]="scope" :key="index">
         <slot :name="item" :scope="scope" v-bind="scope || {}" />
       </template>
@@ -59,11 +62,26 @@ const props = defineProps({
     type: Number,
     default: 0,
   },
+  // x滚动
+  xScroll: {
+    type: Number,
+    default: 0,
+  },
   // 是否分页
   havePage: {
     type: Boolean,
     default: true,
   },
+  // 是否隐藏全选
+  hideSelectAll: {
+    type: Boolean,
+    default: false,
+  },
+  // 单选多选
+  selectType: {
+    type: String,
+    default: 'checkbox',
+  },
   // 分页在右上角
   topRight: {
     type: Boolean,
@@ -79,9 +97,14 @@ const props = defineProps({
     type: Array,
     default: () => [],
   },
+  // 是否自定义行点击
+  isCustomRowClick: {
+    type: Boolean,
+    default: false,
+  },
 });
 
-const emit = defineEmits(['getPager', 'getSorter', 'getSelected']);
+const emit = defineEmits(['getPager', 'getSorter', 'getSelected', 'customRowClick']);
 
 // 分页配置
 const pagination = reactive({
@@ -174,14 +197,19 @@ const handleResizeColumn = (w, col) => {
 
 // 选择每一项操作
 const selectEvent = (record, selected) => {
-  if (selected) {
-    state.selectedRows.push(record);
-    state.selectedRowKeys.push(record.id);
+  if (props.selectType === 'radio') {
+    state.selectedRows = [record];
+    state.selectedRowKeys = [record.id];
   } else {
-    let index = state.selectedRowKeys.indexOf(record.id);
-    if (index >= 0) {
-      state.selectedRows.splice(index, 1);
-      state.selectedRowKeys.splice(index, 1);
+    if (selected) {
+      state.selectedRows.push(record);
+      state.selectedRowKeys.push(record.id);
+    } else {
+      let index = state.selectedRowKeys.indexOf(record.id);
+      if (index >= 0) {
+        state.selectedRows.splice(index, 1);
+        state.selectedRowKeys.splice(index, 1);
+      }
     }
   }
   emit('getSelected', state);
@@ -237,6 +265,15 @@ const tableChange = (pagination, filters, sorter) => {
   }
 };
 
+// 自定义行点击
+const customRowClick = record => {
+  return {
+    onDblclick() {
+      emit('customRowClick', record);
+    },
+  };
+};
+
 // 暴露出方法
 defineExpose({ backFirstPage, clear });
 

+ 81 - 67
src/custom/printer/TrayPrinting.vue

@@ -78,9 +78,15 @@
         <div v-if="column.dataIndex === 'printStatus'">
           {{ record.printStatus ? '已打印' : '未打印' }}
         </div>
+        <div v-if="column.dataIndex === 'operate'">
+          <a-button style="width: 80px; margin-left: 12px" type="dashed" @click="cardEpc(record.epc)">
+            发卡
+          </a-button>
+        </div>
       </template>
     </CommonTable>
 
+    <WriteEpc ref="writeEpc" v-model:visible="writeEpcVisible" @ok="closePrintEpc" />
     <Loading v-if="loading" />
   </div>
 </template>
@@ -90,10 +96,10 @@ import Printer from './printer.js';
 import { message } from 'ant-design-vue';
 import CommonTable from '../common/CommonTable.vue';
 import { workBinColumns } from './columns.js';
-import { Common, Notify, PrintEpc } from 'pc-component-v3';
+import { Common, Notify, PrintEpc, WriteEpc } from 'pc-component-v3';
 
 export default {
-  components: { PrintEpc, CommonTable },
+  components: { PrintEpc, CommonTable, WriteEpc },
   data: function () {
     return {
       assetInstanceDtoList: [],
@@ -180,6 +186,7 @@ export default {
       printEpcVisible: false,
       isCardEpc: false,
       selectedIds: [],
+      writeEpcVisible: false,
     };
   },
   computed: {},
@@ -353,76 +360,83 @@ export default {
       window.open(url);
     },
 
-    cardEpc: function () {
-      const _self = this;
-      _self.isCardEpc = true;
-      let recordIds = _self.getSelectedRecordIds();
-      if (recordIds == null || recordIds.length == 0) {
-        Notify.error('提示', '请先选择发卡数据。', false);
-        return;
-      }
 
-      if (recordIds.length > 1) {
-        Notify.error('提示', '至多选择一条发卡数据。', false);
-        return;
-      }
-
-      let contents = [];
-      let contentCards = [];
-
-      $.ajax({
-        url: Common.getApiURL(
-          'AssetInstanceResource/print?printPreview=' +
-          false +
-          '&templateId=' +
-          _self.templateId,
-        ),
-        dataType: 'json',
-        type: 'post',
-        contentType: 'application/json',
-        data: JSON.stringify(recordIds),
-        beforeSend: function (request) {
-          Common.addTokenToRequest(request);
-          _self.loading = true;
-        },
-        success: function (datas) {
-          datas.forEach(function (item) {
-            var printItem = {
-              id: null,
-              name: null,
-              content: item,
-            };
-            if (
-              printItem.content == null ||
-              printItem.content.printItems == null ||
-              printItem.content.printItems.length == 0
-            ) {
-              Notify.error('错误', '打印模板无数据,不能打印。');
-              return;
-            }
-            var content = JSON.stringify(printItem.content);
-            if (content == null || content == '' || content == '{}') {
-              Notify.error('错误', '请先选择模板,再点击下载。');
-              return;
-            }
-            contents.push(printItem.content);
-          });
-          _self.printEpcVisible = true;
-          _self.$refs.printEpc.printPrintPages(contents);
-          _self.loading = false;
-          _self.isCardEpc = false;
-        },
-        error: function (XMLHttpRequest, textStatus, errorThrown) {
-          _self.loading = false;
-          _self.isCardEpc = false;
-          Common.processException(XMLHttpRequest, textStatus, errorThrown);
-        },
-      });
+    cardEpc: function (epc) {
+      const _self = this;
+      _self.writeEpcVisible = true;
+      _self.$refs.writeEpc.writeSingleEpc(epc);
     },
 
+    // cardEpc: function () {
+    //   const _self = this;
+    //   _self.isCardEpc = true;
+    //   let recordIds = _self.getSelectedRecordIds();
+    //   if (recordIds == null || recordIds.length == 0) {
+    //     Notify.error('提示', '请先选择发卡数据。', false);
+    //     return;
+    //   }
+
+    //   if (recordIds.length > 1) {
+    //     Notify.error('提示', '至多选择一条发卡数据。', false);
+    //     return;
+    //   }
+
+    //   let contents = [];
+    //   let contentCards = [];
+
+    //   $.ajax({
+    //     url: Common.getApiURL(
+    //       'AssetInstanceResource/print?printPreview=' +
+    //       false +
+    //       '&templateId=' +
+    //       _self.templateId,
+    //     ),
+    //     dataType: 'json',
+    //     type: 'post',
+    //     contentType: 'application/json',
+    //     data: JSON.stringify(recordIds),
+    //     beforeSend: function (request) {
+    //       Common.addTokenToRequest(request);
+    //       _self.loading = true;
+    //     },
+    //     success: function (datas) {
+    //       datas.forEach(function (item) {
+    //         var printItem = {
+    //           id: null,
+    //           name: null,
+    //           content: item,
+    //         };
+    //         if (
+    //           printItem.content == null ||
+    //           printItem.content.printItems == null ||
+    //           printItem.content.printItems.length == 0
+    //         ) {
+    //           Notify.error('错误', '打印模板无数据,不能打印。');
+    //           return;
+    //         }
+    //         var content = JSON.stringify(printItem.content);
+    //         if (content == null || content == '' || content == '{}') {
+    //           Notify.error('错误', '请先选择模板,再点击下载。');
+    //           return;
+    //         }
+    //         contents.push(printItem.content);
+    //       });
+    //       _self.printEpcVisible = true;
+    //       _self.$refs.printEpc.printPrintPages(contents);
+    //       _self.loading = false;
+    //       _self.isCardEpc = false;
+    //     },
+    //     error: function (XMLHttpRequest, textStatus, errorThrown) {
+    //       _self.loading = false;
+    //       _self.isCardEpc = false;
+    //       Common.processException(XMLHttpRequest, textStatus, errorThrown);
+    //     },
+    //   });
+    // },
+
     closePrintEpc: function () {
       const _self = this;
-      _self.printEpcVisible = false;
+      _self.writeEpcVisible = false;
     },
 
     /**

+ 80 - 67
src/custom/printer/WorkBinPrinting.vue

@@ -78,9 +78,15 @@
         <div v-if="column.dataIndex === 'printStatus'">
           {{ record.printStatus ? '已打印' : '未打印' }}
         </div>
+        <div v-if="column.dataIndex === 'operate'">
+          <a-button style="width: 80px; margin-left: 12px" type="dashed" @click="cardEpc(record.epc)">
+            发卡
+          </a-button>
+        </div>
       </template>
     </CommonTable>
 
+    <WriteEpc ref="writeEpc" v-model:visible="writeEpcVisible" @ok="closePrintEpc" />
     <Loading v-if="loading" />
   </div>
 </template>
@@ -90,10 +96,10 @@ import Printer from './printer.js';
 import { message } from 'ant-design-vue';
 import CommonTable from '../common/CommonTable.vue';
 import { workBinColumns } from './columns.js';
-import { Common, Notify, PrintEpc } from 'pc-component-v3';
+import { Common, Notify, PrintEpc, writeEpc } from 'pc-component-v3';
 
 export default {
-  components: { PrintEpc, CommonTable },
+  components: { PrintEpc, CommonTable, writeEpc },
   data: function () {
     return {
       assetInstanceDtoList: [],
@@ -180,6 +186,7 @@ export default {
       printEpcVisible: false,
       isCardEpc: false,
       selectedIds: [],
+      writeEpcVisible: false,
     };
   },
   computed: {},
@@ -353,76 +360,82 @@ export default {
       window.open(url);
     },
 
-    cardEpc: function () {
+    cardEpc: function (epc) {
       const _self = this;
-      _self.isCardEpc = true;
-      let recordIds = _self.getSelectedRecordIds();
-      if (recordIds == null || recordIds.length == 0) {
-        Notify.error('提示', '请先选择发卡数据。', false);
-        return;
-      }
-
-      if (recordIds.length > 1) {
-        Notify.error('提示', '至多选择一条发卡数据。', false);
-        return;
-      }
-
-      let contents = [];
-      let contentCards = [];
-
-      $.ajax({
-        url: Common.getApiURL(
-          'AssetInstanceResource/print?printPreview=' +
-          false +
-          '&templateId=' +
-          _self.templateId,
-        ),
-        dataType: 'json',
-        type: 'post',
-        contentType: 'application/json',
-        data: JSON.stringify(recordIds),
-        beforeSend: function (request) {
-          Common.addTokenToRequest(request);
-          _self.loading = true;
-        },
-        success: function (datas) {
-          datas.forEach(function (item) {
-            var printItem = {
-              id: null,
-              name: null,
-              content: item,
-            };
-            if (
-              printItem.content == null ||
-              printItem.content.printItems == null ||
-              printItem.content.printItems.length == 0
-            ) {
-              Notify.error('错误', '打印模板无数据,不能打印。');
-              return;
-            }
-            var content = JSON.stringify(printItem.content);
-            if (content == null || content == '' || content == '{}') {
-              Notify.error('错误', '请先选择模板,再点击下载。');
-              return;
-            }
-            contents.push(printItem.content);
-          });
-          _self.printEpcVisible = true;
-          _self.$refs.printEpc.printPrintPages(contents);
-          _self.loading = false;
-          _self.isCardEpc = false;
-        },
-        error: function (XMLHttpRequest, textStatus, errorThrown) {
-          _self.loading = false;
-          _self.isCardEpc = false;
-          Common.processException(XMLHttpRequest, textStatus, errorThrown);
-        },
-      });
+      _self.writeEpcVisible = true;
+      _self.$refs.writeEpc.writeSingleEpc(epc);
     },
 
+    // cardEpc: function () {
+    //   const _self = this;
+    //   _self.isCardEpc = true;
+    //   let recordIds = _self.getSelectedRecordIds();
+    //   if (recordIds == null || recordIds.length == 0) {
+    //     Notify.error('提示', '请先选择发卡数据。', false);
+    //     return;
+    //   }
+
+    //   if (recordIds.length > 1) {
+    //     Notify.error('提示', '至多选择一条发卡数据。', false);
+    //     return;
+    //   }
+
+    //   let contents = [];
+    //   let contentCards = [];
+
+    //   $.ajax({
+    //     url: Common.getApiURL(
+    //       'AssetInstanceResource/print?printPreview=' +
+    //       false +
+    //       '&templateId=' +
+    //       _self.templateId,
+    //     ),
+    //     dataType: 'json',
+    //     type: 'post',
+    //     contentType: 'application/json',
+    //     data: JSON.stringify(recordIds),
+    //     beforeSend: function (request) {
+    //       Common.addTokenToRequest(request);
+    //       _self.loading = true;
+    //     },
+    //     success: function (datas) {
+    //       datas.forEach(function (item) {
+    //         var printItem = {
+    //           id: null,
+    //           name: null,
+    //           content: item,
+    //         };
+    //         if (
+    //           printItem.content == null ||
+    //           printItem.content.printItems == null ||
+    //           printItem.content.printItems.length == 0
+    //         ) {
+    //           Notify.error('错误', '打印模板无数据,不能打印。');
+    //           return;
+    //         }
+    //         var content = JSON.stringify(printItem.content);
+    //         if (content == null || content == '' || content == '{}') {
+    //           Notify.error('错误', '请先选择模板,再点击下载。');
+    //           return;
+    //         }
+    //         contents.push(printItem.content);
+    //       });
+    //       _self.printEpcVisible = true;
+    //       _self.$refs.printEpc.printPrintPages(contents);
+    //       _self.loading = false;
+    //       _self.isCardEpc = false;
+    //     },
+    //     error: function (XMLHttpRequest, textStatus, errorThrown) {
+    //       _self.loading = false;
+    //       _self.isCardEpc = false;
+    //       Common.processException(XMLHttpRequest, textStatus, errorThrown);
+    //     },
+    //   });
+    // },
+
     closePrintEpc: function () {
       const _self = this;
-      _self.printEpcVisible = false;
+      _self.writeEpcVisible = false;
     },
 
     /**

+ 5 - 0
src/custom/printer/columns.js

@@ -66,4 +66,9 @@ export const workBinColumns = [
     key: 'printStatus',
     dataIndex: 'printStatus',
   },
+  {
+    title: '操作列',
+    key: 'operate',
+    dataIndex: 'operate',
+  },
 ].map(item => ({ ...item, align: 'center', resizable: true, maxWidth: 300, minWidth: 75 }));