소스 검색

refactor(table): tableDialog -> RadioTableDialog or SelectionTableDialog

Casper Dai 3 년 전
부모
커밋
65d9cbfbb1

+ 7 - 5
src/api/asset.js

@@ -232,14 +232,16 @@ export function getDevicesByDataset (query) {
   })
 }
 
-export function bindAssetToDataset (datasetId, asset) {
+export function bindAssetsToDataset (datasetId, assets) {
   return send({
     url: '/media/dataset/batchBindAsset',
     method: 'POST',
-    data: [{
-      datasetId,
-      ...asset
-    }]
+    data: assets.map(item => {
+      return {
+        datasetId,
+        ...item
+      }
+    })
   })
 }
 

+ 2 - 2
src/api/device.js

@@ -326,11 +326,11 @@ export function getDeviceTree () {
   })
 }
 
-export function addDeviceToGroup (id, deviceId) {
+export function addDevicesToGroup (id, deviceIds) {
   return add({
     url: `/deviceGroup/${id}/device`,
     method: 'POST',
-    data: [].concat(deviceId)
+    data: deviceIds
   })
 }
 

+ 2 - 2
src/components/service/EventTargetPicker/index.vue

@@ -61,10 +61,10 @@
     />
     <selection-table-dialog
       ref="assetTableDialog"
-      title="上播内容选择"
-      :schema="assetTableSchema"
       size="medium"
+      title="上播内容选择"
       message="请选择上播内容"
+      :schema="assetTableSchema"
       append-to-body
       @confirm="onChoosenAsset"
     />

+ 1 - 1
src/views/ad/contract/index.vue

@@ -152,8 +152,8 @@
     <selection-table-dialog
       ref="assetTableDialog"
       title="上播内容选择"
-      :schema="assetTableSchema"
       message="请选择上播内容"
+      :schema="assetTableSchema"
       @confirm="onChoosenAssets"
     />
     <preview-dialog ref="previewDialog" />

+ 14 - 11
src/views/ad/dataset/index.vue

@@ -26,15 +26,16 @@
       </confirm-dialog>
       <table-dialog
         ref="assetDialog"
-        :title="assetDialogName"
         size="lg fixed"
+        :title="assetDialogName"
         :schema="assetSchema"
       />
-      <table-dialog
+      <selection-table-dialog
         ref="assetTableDialog"
         title="上播内容选择"
+        message="请选择上播内容"
         :schema="assetTableSchema"
-        @choosen="onChoosenAsset"
+        @confirm="onChoosenAsset"
       />
       <table-dialog
         ref="deviceDialog"
@@ -63,7 +64,7 @@ import {
   updateDataset,
   getDataset,
   deleteDataset,
-  bindAssetToDataset,
+  bindAssetsToDataset,
   unbindAssetsFromDataset,
   getDevicesByDataset,
   updateDatasetAssetDuration
@@ -213,13 +214,15 @@ export default {
       this.$refs.assetTableDialog.show()
     },
     onChoosenAsset ({ value, done }) {
-      const { tag, type, keyName } = value
-      bindAssetToDataset(this.$datasetId, {
-        tag,
-        type,
-        keyName,
-        adDuration: getAssetDuration(value)
-      }).then(() => {
+      bindAssetsToDataset(this.$datasetId, value.map(asset => {
+        const { tag, type, keyName } = asset
+        return {
+          tag,
+          type,
+          keyName,
+          adDuration: getAssetDuration(asset)
+        }
+      })).then(() => {
         done()
         this.$refs.assetDialog.getTable().pageTo()
       })

+ 2 - 2
src/views/ad/task/index.vue

@@ -19,8 +19,8 @@
     />
     <table-dialog
       ref="contentDialog"
-      title="上播内容"
       size="medium"
+      title="上播内容"
       :schema="contentSchema"
     />
     <asset-task-dialog
@@ -31,8 +31,8 @@
     <radio-table-dialog
       ref="contractTableDialog"
       title="新增合同任务"
-      :schema="contractTableSchema"
       message="请选择合同"
+      :schema="contractTableSchema"
       @confirm="onSubmitContractTask"
     />
     <preview-dialog ref="previewDialog" />

+ 1 - 1
src/views/device/detail/components/DeviceRuntime/Download.vue

@@ -22,9 +22,9 @@
       正在下载文件...
     </div>
     <el-dialog
-      title="文件下载详情"
       :visible.sync="showProgress"
       custom-class="c-dialog"
+      title="文件下载详情"
       append-to-body
     >
       <download-progress @update="onUpdate" />

+ 16 - 30
src/views/device/group/index.vue

@@ -35,16 +35,17 @@
     </confirm-dialog>
     <table-dialog
       ref="subDeviceDialog"
+      size="lg fixed"
       :title="groupName"
       :schema="subDeviceSchema"
-      size="lg fixed"
     />
-    <table-dialog
+    <selection-table-dialog
       ref="deviceDialog"
       title="添加设备"
+      message="请选择设备"
       :schema="deviceSchema"
       append-to-body
-      @choosen="onChoosenDevice"
+      @confirm="onChoosenDevices"
     />
   </wrapper>
 </template>
@@ -57,7 +58,7 @@ import {
   deleteDeviceGroup,
   getDevicesByGroup,
   getDevices,
-  addDeviceToGroup,
+  addDevicesToGroup,
   deleteDeviceFromGroup
 } from '@/api/device'
 
@@ -96,7 +97,6 @@ export default {
           { prop: 'name', label: '设备名称' },
           { prop: 'serialNumber', label: '序列号' },
           { prop: 'mac', label: 'MAC' },
-          { prop: 'resolutionRatio', label: '分辨率' },
           { prop: 'address', label: '地址' },
           { type: 'invoke', width: 80, render: [
             { label: '移除', on: this.onDelDevice }
@@ -111,7 +111,6 @@ export default {
         list: getDevices,
         cols: [
           { prop: 'name', label: '设备名称' },
-          { prop: 'resolutionRatio', label: '分辨率', width: 120 },
           { prop: 'address', label: '地址' }
         ]
       },
@@ -168,47 +167,34 @@ export default {
       })
     },
     onViewDevices ({ id, name }) {
+      this.$groupId = id
       this.$devices = null
       this.groupName = name
-      this.$refs.subDeviceDialog.show({ id })
+      this.$refs.subDeviceDialog.show()
     },
-    getDevicesByGroup ({ id }) {
+    getDevicesByGroup () {
       if (this.$devices) {
         return Promise.resolve({ data: this.$devices })
       }
-      return getDevicesByGroup(id).then(({ data }) => {
+      return getDevicesByGroup(this.$groupId).then(({ data }) => {
         this.$devices = data
         return { data }
       })
     },
     onDelDevice (device) {
-      const table = this.$refs.subDeviceDialog.getTable()
-      deleteDeviceFromGroup(table.getCondition().id, device).then(() => {
+      deleteDeviceFromGroup(this.$groupId, device).then(() => {
         this.$devices = null
-        table.decrease(1)
+        this.$refs.subDeviceDialog.getTable().decrease(1)
       })
     },
     onAddDevice () {
       this.$refs.deviceDialog.show()
     },
-    canJoin (device) {
-      const data = this.$refs.subDeviceDialog.getTable().getData()
-      if (data.length === 0 || data.some(({ resolutionRatio }) => device.resolutionRatio === resolutionRatio)) {
-        return Promise.resolve()
-      }
-      return this.$confirm(
-        `设备 ${device.name} 与分组中的设备分辨率不一致,确定加入分组?`,
-        { type: 'warning' }
-      )
-    },
-    onChoosenDevice ({ value, done }) {
-      const table = this.$refs.subDeviceDialog.getTable()
-      this.canJoin(value).then(() => {
-        addDeviceToGroup(table.getCondition().id, value.id).then(() => {
-          done()
-          this.$devices = null
-          table.pageTo(1)
-        })
+    onChoosenDevices ({ value, done }) {
+      addDevicesToGroup(this.$groupId, value.map(({ id }) => id)).then(() => {
+        done()
+        this.$devices = null
+        this.$refs.subDeviceDialog.getTable().pageTo(1)
       })
     }
   }

+ 10 - 12
src/views/external/gateway/index.vue

@@ -41,21 +41,19 @@
     </confirm-dialog>
     <el-dialog
       :visible.sync="showSubDialog"
-      :title="subDialogTitle"
       custom-class="c-dialog medium"
+      :title="subDialogTitle"
       :close-on-click-modal="false"
-      @close="onCloseSubDialog"
+      @closed="onCloseSubDialog"
     >
-      <template v-if="showSubDialog">
-        <plc
-          v-if="showPLC"
-          :gateway="gateway"
-        />
-        <sensor
-          v-if="showSensor"
-          :gateway="gateway"
-        />
-      </template>
+      <plc
+        v-if="showPLC"
+        :gateway="gateway"
+      />
+      <sensor
+        v-if="showSensor"
+        :gateway="gateway"
+      />
     </el-dialog>
   </wrapper>
 </template>

+ 2 - 2
src/views/platform/ai-stock/Assign.vue

@@ -6,11 +6,11 @@
         class="c-sibling-item far"
         :schema="schema"
       />
-      <table-dialog
+      <radio-table-dialog
         ref="stockDialog"
         title="库存"
         :schema="stockSchema"
-        @choosen="onChoosen"
+        @confirm="onChoosen"
       />
       <confirm-dialog
         ref="addDialog"

+ 5 - 8
src/views/platform/tenant/device/settings/components/DatasetConfigDialog.vue

@@ -3,7 +3,6 @@
     :visible.sync="dialogVisible"
     custom-class="c-dialog medium"
     :title="title"
-    :before-close="onCancel"
   >
     <div
       v-if="isUnbound"
@@ -22,12 +21,13 @@
       :schema="assetSchema"
     />
     <preview-dialog ref="previewDialog" />
-    <table-dialog
+    <radio-table-dialog
       ref="datasetDialog"
       title="填充素材包"
+      message="请选择填充素材包"
       :schema="schema"
       append-to-body
-      @choosen="onBindDataset"
+      @confirm="onBindDataset"
     />
   </el-dialog>
 </template>
@@ -53,7 +53,7 @@ export default {
     return {
       dialogVisible: false,
       isUnbound: false,
-      title: '绑定素材包配置',
+      title: '绑定填充素材包',
       assetSchema: {
         buttons: [
           { label: '重新绑定', on: this.onBind }
@@ -88,15 +88,12 @@ export default {
       getDatasetByDevice(this.$deviceId).then(({ data }) => {
         this.isUnbound = !data
         this.dataset = data
-        this.title = data ? data.name : '绑定素材包配置'
+        this.title = data ? data.name : '绑定填充素材包'
         this.dialogVisible = true
       }).finally(() => {
         this.$closeLoading(loading)
       })
     },
-    onCancel () {
-      this.dialogVisible = false
-    },
     getAssetsByDataset () {
       if (this.dataset) {
         return Promise.resolve({

+ 3 - 2
src/views/platform/tenant/device/settings/components/external/Camera/index.vue

@@ -49,11 +49,12 @@
         </camera-player>
       </grid-table-item>
     </grid-table>
-    <table-dialog
+    <radio-table-dialog
       ref="tableDialog"
       :title="title"
+      message="请选择需绑定的摄像头"
       :schema="cameraSchema"
-      @choosen="onCameraChoosen"
+      @confirm="onCameraChoosen"
     />
     <camera-dialog
       ref="cameraDialog"

+ 12 - 3
src/views/platform/tenant/device/settings/components/external/Gateway/index.vue

@@ -131,11 +131,12 @@
         </div>
       </template>
     </template>
-    <table-dialog
+    <radio-table-dialog
       ref="chooseDialog"
       :title="dialogTitle"
+      :message="dialogMessage"
       :schema="schema"
-      @choosen="onChoose"
+      @confirm="onChoosen"
     />
   </div>
 </template>
@@ -182,6 +183,14 @@ export default {
           return '网关选择'
       }
     },
+    dialogMessage () {
+      switch (this.deviceType) {
+        case 'PLC':
+          return '请选择需要绑定的PLC'
+        default:
+          return '请选择需要绑定的网关'
+      }
+    },
     schema () {
       switch (this.deviceType) {
         case 'PLC':
@@ -259,7 +268,7 @@ export default {
     getBoundPLCs () {
       return getBoundPLCs(this.device.id)
     },
-    onChoose ({ value, done }) {
+    onChoosen ({ value, done }) {
       (this.deviceType === 'PLC' ? bindPLC : bindGateway)(this.device.id, value.id).then(() => {
         done()
         this.getInfo(this.deviceType)

+ 5 - 4
src/views/platform/tenant/device/settings/components/external/SendingCard/index.vue

@@ -81,12 +81,13 @@
         </div>
       </template>
     </template>
-    <table-dialog
+    <radio-table-dialog
       ref="chooseDialog"
-      title="发送控制设备选择"
       size="lg"
+      title="发送控制设备选择"
+      message="请选择需绑定的发送控制设备"
       :schema="schema"
-      @choosen="onChoose"
+      @confirm="onChoosen"
     />
   </div>
 </template>
@@ -184,7 +185,7 @@ export default {
     onBind () {
       this.$refs.chooseDialog.show()
     },
-    onChoose ({ value, done }) {
+    onChoosen ({ value, done }) {
       bindSendingCard(this.device.id, value.id).then(() => {
         done()
         this.getSendingCard()

+ 3 - 2
src/views/platform/upgrade/deploy/index.vue

@@ -53,12 +53,13 @@
         />
       </div>
     </confirm-dialog>
-    <table-dialog
+    <radio-table-dialog
       ref="apkDialog"
       title="目标版本选择"
+      message="请选择目标版本"
       :schema="apkSchema"
       append-to-body
-      @choosen="onChoosenApk"
+      @confirm="onChoosenApk"
     />
     <confirm-dialog
       ref="targetDialog"

+ 1 - 1
src/views/realm/ai/ai-timing/index.vue

@@ -13,9 +13,9 @@
     <strat-config-dialog ref="stratConfigDialog" />
     <table-dialog
       ref="historyDialog"
+      size="medium"
       :title="historyTitle"
       :schema="historySchema"
-      size="medium"
     />
     <device-service-config-dialog ref="deviceServiceConfigDialog" />
     <preview-dialog ref="previewDialog" />

+ 1 - 1
src/views/realm/assign/Device.vue

@@ -5,8 +5,8 @@
   >
     <table-dialog
       ref="tableDialog"
-      title="分配设备"
       size="lg"
+      title="分配设备"
       :schema="deviceSchema"
       @choosen="onChoosen"
     />

+ 3 - 3
src/views/screen/material/program/ast/Designer.vue

@@ -223,7 +223,7 @@
       :title="assetDialogType"
       custom-class="c-dialog medium fixed"
       :close-on-click-modal="false"
-      :before-close="onCloseAssetsDialog"
+      @closed="onCloseAssetsDialog"
     >
       <draggable
         v-if="showAssets"
@@ -354,7 +354,7 @@
     </confirm-dialog>
     <preview-dialog
       ref="previewDialog"
-      @close="onClosePreview"
+      @closed="onClosePreview"
     />
     <confirm-dialog
       ref="rich"
@@ -856,7 +856,7 @@ export default {
       } else {
         this.$message({
           type: 'warning',
-          message: '请选择媒资'
+          message: `请选择${this.assetDialogType}`
         })
       }
     },