|
|
@@ -94,16 +94,30 @@
|
|
|
</a-select>
|
|
|
</a-form-item>
|
|
|
<a-form-item label="选择设备" >
|
|
|
- <a-space>
|
|
|
- <a-tag color="blue" v-if="modalRef.taskConfig.deviceLabel" >{{modalRef.taskConfig.deviceLabel}}</a-tag>
|
|
|
- <a-button
|
|
|
- type="primary"
|
|
|
- @click="state.deviceModalVisible = true"
|
|
|
- >
|
|
|
- {{modalRef.taskConfig.deviceId ? '重新选择' : '请选择设备'}}
|
|
|
- </a-button>
|
|
|
- </a-space>
|
|
|
- </a-form-item>
|
|
|
+ <a-space>
|
|
|
+ <a-tag color="blue" v-if="modalRef.taskConfig.deviceLabel" >{{modalRef.taskConfig.deviceLabel}}</a-tag>
|
|
|
+ <a-button
|
|
|
+ type="primary"
|
|
|
+ @click="state.deviceModalVisible = true"
|
|
|
+ >
|
|
|
+ {{modalRef.taskConfig.deviceId ? '重新选择' : '请选择设备'}}
|
|
|
+ </a-button>
|
|
|
+ </a-space>
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item label="选择命令" >
|
|
|
+ <a-select
|
|
|
+ style="width: 170px;"
|
|
|
+ v-model:value="modalRef.taskConfig.cmdId"
|
|
|
+ >
|
|
|
+ <a-select-option
|
|
|
+ v-for="cmdItem in state.cmdList"
|
|
|
+ :key="cmdItem.id"
|
|
|
+ :value="cmdItem.id"
|
|
|
+ >
|
|
|
+ {{cmdItem.cmdLabel}}
|
|
|
+ </a-select-option>
|
|
|
+ </a-select>
|
|
|
+ </a-form-item>
|
|
|
</a-form>
|
|
|
</modal-pro>
|
|
|
</a-card>
|
|
|
@@ -122,10 +136,9 @@
|
|
|
</template>
|
|
|
<script lang='ts' setup >
|
|
|
import { TaskController } from '@/controller/iot/task'
|
|
|
-import { computed, onMounted, reactive, ref } from 'vue'
|
|
|
+import { computed, onMounted, reactive, ref, watch } from 'vue'
|
|
|
import { Form } from 'ant-design-vue'
|
|
|
-import { string } from 'vue-types'
|
|
|
-import { ModelController } from '@/controller'
|
|
|
+import { ModelAttrController, ModelCmdController, ModelController } from '@/controller'
|
|
|
import SelectDevice from '@/pages/iot/rule/components/selectDevice.vue'
|
|
|
|
|
|
const columns = [
|
|
|
@@ -185,6 +198,8 @@ const state = reactive({
|
|
|
opraState: 'add',
|
|
|
visible: false,
|
|
|
modelList: [],
|
|
|
+ cmdList: [],
|
|
|
+ attrList: [],
|
|
|
deviceModalVisible: false
|
|
|
})
|
|
|
|
|
|
@@ -198,12 +213,25 @@ const modalRef = reactive({
|
|
|
deviceLabel: '',
|
|
|
modelId: '',
|
|
|
cmdLabel: '',
|
|
|
- cmdParameters: {}
|
|
|
+ cmdParameters: {},
|
|
|
+ cmdId: ''
|
|
|
}
|
|
|
})
|
|
|
|
|
|
const selectDeviceRef = ref('')
|
|
|
|
|
|
+// watch(
|
|
|
+// () => modalRef.taskConfig.cmdId,
|
|
|
+// () => {
|
|
|
+// const cmdDetail = state.cmdList.find(item => item.id === initActionsData.cmdId)!
|
|
|
+// console.log('cmdDetail:', cmdDetail)
|
|
|
+
|
|
|
+// modalRef.taskConfig.cmdParameters = cmdDetail.cmdParams
|
|
|
+
|
|
|
+// modalRef.taskConfig.cmdLabel = cmdDetail.cmdLabel
|
|
|
+// }
|
|
|
+// )
|
|
|
+
|
|
|
const { resetFields, validate, validateInfos } = useForm(modalRef, reactive({
|
|
|
taskLabel: [{ required: true, message: '请填写任务名称' }],
|
|
|
cornDescr: [{ required: true, message: '请填写corn表达式' }],
|
|
|
@@ -234,6 +262,17 @@ const changeStatus = (value) => {
|
|
|
queryParamsState.status = value
|
|
|
}
|
|
|
|
|
|
+const getCmdList = async () => {
|
|
|
+ const { data } = await ModelCmdController.list({ modelId: modalRef.taskConfig.modelId })
|
|
|
+ state.cmdList = data
|
|
|
+}
|
|
|
+
|
|
|
+// 获取属性
|
|
|
+const getAttrList = async () => {
|
|
|
+ const { data } = await ModelAttrController.list({ modelId: modalRef.taskConfig.modelId })
|
|
|
+ state.attrList = data
|
|
|
+}
|
|
|
+
|
|
|
const getModelList = async () => {
|
|
|
const { data } = await ModelController.list()
|
|
|
state.modelList = data
|
|
|
@@ -255,6 +294,8 @@ const changePage = ({ current }) => {
|
|
|
onMounted(() => {
|
|
|
getTaskPage()
|
|
|
getModelList()
|
|
|
+ getCmdList()
|
|
|
+ getAttrList()
|
|
|
})
|
|
|
|
|
|
</script>
|