Device.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <script setup lang="ts">
  2. import { ref, reactive } from 'vue'
  3. import { GlobalStore } from '@/stores/index'
  4. import Dialog from '@/components/dialog/Dialog.vue'
  5. import TableBase from '@/components/TableBase/index.vue'
  6. import type { ColumnProps } from '@/components/TableBase/interface/index'
  7. import { Storehouse_Device_List } from '@/api/storehouse/index'
  8. const globalStore = GlobalStore()
  9. const TableRef = ref<InstanceType<typeof TableBase> | null>(null)
  10. const columns: ColumnProps[] = [
  11. { type: 'index', label: '序号', width: 80 },
  12. { prop: 'T_contract_number', label: '合同编号', ellipsis: true },
  13. { prop: 'T_out_number', label: '出库单号', ellipsis: true },
  14. { prop: 'T_product_img', label: '产品图片', name: 'T_product_img' },
  15. { prop: 'T_product_name', label: '产品名称' },
  16. { prop: 'T_product_class_name', label: '产品分类' },
  17. { prop: 'T_product_model', label: '产品型号', ellipsis: true },
  18. { prop: 'T_product_spec', label: '产品规格' },
  19. { prop: 'T_sn', label: '设备SN', ellipsis: true },
  20. { prop: 'T_imei', label: '模组imei', ellipsis: true },
  21. { prop: 'T_iccid', label: '物联网卡号', ellipsis: true },
  22. { prop: 'T_State', label: '状态', name: 'T_State' }
  23. ]
  24. // 查看图片
  25. const url = ref('')
  26. const srcList = ref<any[]>([])
  27. const dialog = ref<InstanceType<typeof Dialog> | null>(null)
  28. const previewImg = (str: string) => {
  29. dialog.value?.DialogOpen()
  30. url.value = str
  31. srcList.value.push(str)
  32. }
  33. // 搜索
  34. const options = reactive([
  35. { name: '已出库', id: 1 },
  36. { name: '未出库', id: 2 }
  37. ])
  38. const initParam = reactive({
  39. User_tokey: globalStore.GET_User_tokey,
  40. T_name: '',
  41. T_state: ''
  42. })
  43. const searchHandle = () => {
  44. TableRef.value?.searchTable()
  45. }
  46. </script>
  47. <template>
  48. <div class="Device">
  49. <TableBase ref="TableRef" :columns="columns" :requestApi="Storehouse_Device_List" :initParam="initParam">
  50. <template #table-header>
  51. <div class="input-suffix">
  52. <el-row :gutter="20" style="margin-bottom: 0">
  53. <el-col :xl="6" :lg="8" :md="10">
  54. <span class="inline-flex items-center">关键字:</span>
  55. <el-input
  56. v-model="initParam.T_name"
  57. type="text"
  58. class="w-50 m-2"
  59. placeholder="按合同编号、出库单号、SN搜索"
  60. @change="searchHandle"
  61. />
  62. </el-col>
  63. <el-col :xl="10" :md="12">
  64. <span class="inline-flex items-center">状态:</span>
  65. <el-select v-model="initParam.T_state" class="w-50" clearable placeholder="请选择状态~">
  66. <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id" />
  67. </el-select>
  68. <el-button type="primary" @click="searchHandle">搜索</el-button>
  69. </el-col>
  70. </el-row>
  71. </div>
  72. </template>
  73. <template #T_State="{ row }">
  74. <el-tag v-if="row.T_State === 1" type="success" effect="dark"> 已出库 </el-tag>
  75. <el-tag v-else type="danger" effect="dark"> 未出库 </el-tag>
  76. </template>
  77. <template #T_product_img="{ row }">
  78. <el-image
  79. v-if="row.T_product_img"
  80. style="height: 50px"
  81. :src="row.T_product_img"
  82. fit="cover"
  83. @click="previewImg(row.T_product_img)"
  84. />
  85. </template>
  86. </TableBase>
  87. <Dialog ref="dialog" width="50%">
  88. <el-image :src="url" :zoom-rate="1.2" :preview-src-list="srcList" fit="cover" />
  89. </Dialog>
  90. </div>
  91. </template>
  92. <style scoped lang="scss">
  93. @import '@/styles/var.scss';
  94. .Device {
  95. @include f-direction;
  96. .input-suffix {
  97. width: 100%;
  98. .inline-flex {
  99. white-space: nowrap;
  100. }
  101. .w-50 {
  102. width: 14.5rem;
  103. }
  104. }
  105. }
  106. </style>