actionSerialItem.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <div class="type-item">
  3. <div v-for="(item, index) in seriallist" :key="index" class="item " :class="index > 0 ? 'biankang' : ''">
  4. <div class="conicon" style="width: 100%; text-align: right; position: relative; right: -8px; top: -8px; color: red"
  5. v-if="index > 0">
  6. <el-icon @click="delScene(index)">
  7. <CircleClose />
  8. </el-icon>
  9. </div>
  10. <div class="product flex flex-warp">
  11. <el-form-item label="动作类型:" prop="product_key">
  12. <el-select v-model="item.product_key" filterable placeholder="请选择动作类型">
  13. <el-option v-for="it in sourceActionTypeData" :key="it.key" :label="it.name" :value="it.key">
  14. <span style="float: left">{{ it.name }}</span>
  15. <span style="float: right; font-size: 13px">{{ it.key }}</span>
  16. </el-option>
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="用户类型:" prop="device_key">
  20. <el-select v-model="item.device_key" filterable placeholder="请选择设备">
  21. <el-option v-for="it in sourceData" :key="it.key" :label="it.name" :value="it.key">
  22. <span style="float: left">{{ it.name }}</span>
  23. <span style="float: right; font-size: 13px">{{ it.key }}</span>
  24. </el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="触发类型:" prop="type">
  28. <el-select v-model="item.type" filterable placeholder="请选择触发类型">
  29. <el-option v-for="it in sourceData" :key="it.key" :label="it.name" :value="it.key">
  30. <span style="float: left">{{ it.name }}</span>
  31. <span style="float: right; font-size: 13px">{{ it.key }}</span>
  32. </el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="属性:" prop="type">
  36. <el-select v-model="item.type" filterable placeholder="请选择触发类型">
  37. <el-option v-for="it in sourceData" :key="it.key" :label="it.name" :value="it.key">
  38. <span style="float: left">{{ it.name }}</span>
  39. <span style="float: right; font-size: 13px">{{ it.key }}</span>
  40. </el-option>
  41. </el-select>
  42. </el-form-item>
  43. </div>
  44. </div>
  45. <div>
  46. <div class=" flex-center">
  47. <el-button :icon="DocumentAdd" @click="addScene()" style="border: 1px solid #409eff;color: #409eff;">新增串行动作</el-button>
  48. </div>
  49. </div>
  50. </div>
  51. </template>
  52. <script lang="ts" setup>
  53. import { PropType, ref } from 'vue'
  54. import { DocumentAdd, CircleClose } from '@element-plus/icons-vue';
  55. interface IConditionItem {
  56. param?: string;
  57. operator?: string;
  58. value?: string;
  59. }
  60. interface IValueType {
  61. seriallist?: IConditionItem[] ;
  62. }
  63. interface testIValueType {
  64. key: string;
  65. name?: string;
  66. }
  67. const props = defineProps({
  68. seriallist: {
  69. type: Array as PropType<IValueType[]>,
  70. default: () => []
  71. },
  72. sourceData: {
  73. type: Array as PropType<testIValueType[]>,
  74. default: () => [{
  75. 'key': 'test',
  76. 'name': '测试',
  77. }, {
  78. 'key': 'test',
  79. 'name': '测试',
  80. }, {
  81. 'key': 'test',
  82. 'name': '测试',
  83. }, {
  84. 'key': 'test',
  85. 'name': '测试',
  86. }, {
  87. 'key': 'test',
  88. 'name': '测试',
  89. }]
  90. },
  91. sourceActionTypeData: {
  92. type: Array as PropType<testIValueType[]>,
  93. default: () => [{
  94. 'key': 'deviceOutput',
  95. 'name': '设备输出',
  96. }, {
  97. 'key': 'sendNotice',
  98. 'name': '发送通知',
  99. }, {
  100. 'key': 'callWebService',
  101. 'name': '调用WEB服务',
  102. }, {
  103. 'key': "triggerAlarm",
  104. 'name': '触发告警',
  105. }, {
  106. 'key': 'delayExecution',
  107. 'name': '延迟执行',
  108. }, {
  109. 'key': 'triggerCustomEvent',
  110. 'name': '触发场景自定义事件',
  111. }]
  112. }
  113. })
  114. const addScene = () => {
  115. props.seriallist.push({
  116. 'product_key': '',
  117. 'device_key': '',
  118. 'type': '',
  119. 'condition':[{
  120. 'list': [{
  121. 'param': '',
  122. 'operator': '',
  123. 'value': ''
  124. }]
  125. }]
  126. });
  127. console.log(props.seriallist);
  128. };
  129. const delScene = (index: number) => {
  130. props.seriallist.splice(index, 1);
  131. }
  132. </script>
  133. <style scoped lang="scss">
  134. .type-item {
  135. width: 100%;
  136. .edit {
  137. margin-left: 10px;
  138. color: #2041d4;
  139. }
  140. .conicon {
  141. width: 55px;
  142. height: 25px;
  143. font-size: 28px;
  144. line-height: 28px;
  145. cursor: pointer;
  146. }
  147. .item {
  148. margin-bottom: 20px;
  149. }
  150. .biankang {
  151. border: 1px dashed #959596;;
  152. border-radius: 10px;
  153. }
  154. .title {
  155. height: 40px;
  156. .icon {
  157. margin-left: 2px;
  158. margin-right: 10px;
  159. width: 5px;
  160. height: 20px;
  161. background-color: #315efb;
  162. }
  163. }
  164. .product {
  165. margin-bottom: 20px;
  166. .el-form-item {
  167. margin-left: 30px;
  168. margin-bottom: 10px;
  169. }
  170. }
  171. }
  172. </style>