SymptomPush.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template>
  2. <div class="symptomPushWrapper clearfix">
  3. <div class="symptomPushBottomPartLeft">
  4. <p class="symptomPushPoolTitle">标签池</p>
  5. <div class="symptomPushPool">
  6. <el-input
  7. placeholder="请输入搜索内容"
  8. v-model="searchVal"
  9. >
  10. <i
  11. slot="prefix"
  12. class="el-input__icon el-icon-search"
  13. ></i>
  14. </el-input>
  15. <ul class="symptomPushTagList symptomPushTagPool">
  16. <li v-for="(item, index) in leftTagsList"
  17. class = "symptomPushTagItem"
  18. :key='item.id'
  19. :title="'[ '+item.tagName+' ]'"
  20. :style="getStyle(item)?styles:null"
  21. @click='selectLeftTag(item, index, $event)'
  22. >
  23. <p class="symptomPushTagName ellipsis" >{{item.tagName}} </p>
  24. </li>
  25. </ul>
  26. </div>
  27. </div>
  28. <div class="symptomPushBottomPartMid fl">
  29. <p><span class="el-icon-arrow-right" @click="toRightList"></span></p>
  30. <p><span class="el-icon-arrow-left" @click="toLeftList"></span></p>
  31. </div>
  32. <div class="symptomPushBottomPartRight ">
  33. <p class="symptomPushPoolTitle">操作界面:</p>
  34. <ul v-for="(item, index) in rightTagsList"
  35. :key="index"
  36. class="symptomPushTagList symptomPushOperationPool"
  37. :class="{symptomPushOperationPoolPush:index === 1, hasSymptomPush: index === 1&&item.id} "
  38. :style="currentSelectIndex === index?styles:null"
  39. @click="SelectList(index)"
  40. >
  41. <li v-if="index===1" class = "symptomPushTagItemPushBox">
  42. <p class = "symptomPushTagItemPush" v-if="index===1">此处放置推送模块</p>
  43. </li>
  44. <li
  45. v-for="(it) in item.questionDetailList"
  46. :key = "it.id"
  47. class = "symptomPushTagItem">
  48. {{it.name}}
  49. </li>
  50. </ul>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. import api from '@api/icss.js';
  56. import utils from '@api/utils.js';
  57. export default {
  58. name: "SymptomPush",
  59. props: {
  60. pool: {
  61. default: () => [],
  62. type: Array
  63. },
  64. type: {
  65. default: '',
  66. type: String
  67. },
  68. sexType: {
  69. default: '',
  70. type: String
  71. },
  72. options: {
  73. default: () => [],
  74. type: Array
  75. }
  76. },
  77. data() {
  78. return {
  79. leftTagsList: [],
  80. selectLeftTagId: {},
  81. rightTagsList: [{}, {}],
  82. currentSelectIndex: -1,
  83. searchVal: '',
  84. styles:{
  85. background:'#eae7e7'
  86. },
  87. }
  88. },
  89. mounted() {
  90. if(this.options.length) {
  91. if(this.options.length === 2) { //当两个模块都有值时
  92. this.rightTagsList = this.options
  93. this.$emit('changeActionData',this.rightTagsList, false);
  94. } else if(this.options.length === 1) {
  95. this.options[0].controlType == 99 ? this.rightTagsList.splice(1, 1, this.options[0]) :this.rightTagsList.splice(0, 1, this.options[0])
  96. }
  97. this.searchTagList()
  98. }
  99. },
  100. watch: {
  101. pool(newVal, preVal) {
  102. if (JSON.stringify(newVal) != JSON.stringify(preVal)) {
  103. this.leftTagsList = newVal
  104. }
  105. },
  106. searchVal(newVal, preVal){
  107. if(newVal.trim() == ''){
  108. this.searchTagList()
  109. }else if(newVal.trim() != preVal.trim()){
  110. this.searchTagList()
  111. }
  112. },
  113. sexType(newVal, preVal) {
  114. },
  115. },
  116. methods: {
  117. selectLeftTag(tag, index, e) {
  118. let isFull = true
  119. for(let i = 0; i < this.rightTagsList.length; i++) {
  120. if(Object.keys(this.rightTagsList[i]).length === 0) {
  121. isFull = false
  122. break;
  123. }
  124. }
  125. if (isFull && this.currentSelectIndex === -1) {
  126. return
  127. }
  128. this.selectLeftTagId = tag
  129. console.log(this.selectLeftTagId)
  130. },
  131. getStyle(item){ //左侧选中状态
  132. return item.id == this.selectLeftTagId.id
  133. },
  134. toLeftList() {
  135. if(this.currentSelectIndex === -1) {
  136. return
  137. }
  138. this.rightTagsList.splice(this.currentSelectIndex, 1, { })
  139. this.selectLeftTagId = {}
  140. this.searchTagList()
  141. this.$emit('changeActionData',this.rightTagsList, false);
  142. },
  143. toRightList() {
  144. if(Object.keys(this.selectLeftTagId).length === 0) { //判断标签池有没有选中标签
  145. this.$message({
  146. showClose: true,
  147. message: '请选择标签池',
  148. type: 'warning'
  149. });
  150. return
  151. }
  152. let fillIndex = -1
  153. if(this.currentSelectIndex === -1) { //操作界面没有选择模块时
  154. for(let i = 0; i < this.rightTagsList.length; i++) {
  155. if(Object.keys(this.rightTagsList[i]).length === 0) {
  156. fillIndex = i
  157. break
  158. }
  159. }
  160. } else {
  161. fillIndex = this.currentSelectIndex
  162. }
  163. if(fillIndex === -1) {
  164. this.$message({
  165. showClose: true,
  166. message: '请选择标签池',
  167. type: 'warning'
  168. });
  169. return;
  170. } else {
  171. this.getcontrolType(fillIndex)
  172. }
  173. },
  174. getcontrolType(fillIndex) {
  175. if(fillIndex === 0) {
  176. if(this.selectLeftTagId.controlType != 99) {
  177. this.getRighDetailsTag(fillIndex)
  178. } else {
  179. this.$message({
  180. showClose: true,
  181. message: '请选择正确的标签类型',
  182. type: 'warning'
  183. });
  184. return;
  185. }
  186. } else if (fillIndex === 1) {
  187. if(this.selectLeftTagId.controlType == 99) {
  188. this.rightTagsList.splice(fillIndex, 1, this.selectLeftTagId)
  189. this.searchTagList()
  190. this.$emit('changeActionData',this.rightTagsList, false);
  191. } else {
  192. this.$message({
  193. showClose: true,
  194. message: '请选择正确的标签类型',
  195. type: 'warning'
  196. });
  197. return;
  198. }
  199. }
  200. },
  201. searchTagList() {
  202. let notIds = []
  203. for (let i = 0; i < this.rightTagsList.length; i++) {
  204. if(this.rightTagsList[i].id) {
  205. notIds.push(this.rightTagsList[i].id)
  206. }
  207. }
  208. let param = {
  209. "tagName": this.searchVal,
  210. "tagType": [1],
  211. "controlType": [1,2,99],
  212. "type": this.type || '',
  213. "notIds": notIds,
  214. "sexType": this.sexType,
  215. }
  216. api.searchTagList(param).then((res) => {
  217. if (res.data.code === '0') {
  218. this.leftTagsList = res.data.data
  219. }
  220. })
  221. },
  222. getRighDetailsTag(fillIndex) {
  223. let param = {
  224. // "age": 0,
  225. "id": this.selectLeftTagId.id,
  226. // "sexType": 3
  227. }
  228. api.detailsTag(param).then((res) =>{
  229. if (res.data.code === '0') {
  230. this.selectLeftTagId = res.data.data
  231. if(this.currentSelectIndex !== -1) {
  232. // this.rightTagsList[this.currentSelectIndex] = this.selectLeftTagId;
  233. this.rightTagsList.splice(this.currentSelectIndex, 1, this.selectLeftTagId)
  234. } else {
  235. for(let i = 0; i < this.rightTagsList.length; i++) {
  236. if(Object.keys(this.rightTagsList[i]).length === 0) {
  237. this.rightTagsList.splice(i, 1, this.selectLeftTagId)
  238. break;
  239. }
  240. }
  241. }
  242. this.searchTagList()
  243. this.$emit('changeActionData',this.rightTagsList, false);
  244. }
  245. })
  246. },
  247. SelectList(index) {
  248. this.currentSelectIndex = this.currentSelectIndex === index ? -1 : index;
  249. }
  250. }
  251. }
  252. </script>
  253. <style lang="less" >
  254. @import '../../less/common.less';
  255. .symptomPushWrapper {
  256. .symptomPushBottomPartLeft {
  257. width: 30%;
  258. box-sizing: border-box;
  259. float: left;
  260. }
  261. .symptomPushPoolTitle {
  262. // border-bottom: 1px solid @icssBorder;
  263. box-sizing: border-box;
  264. margin-bottom: 20px;
  265. }
  266. .symptomPushPool {
  267. // border:1px solid @icssBorder;
  268. }
  269. .symptomPushSearch {
  270. width: 100%;
  271. border-bottom: 1px solid @icssBorder;
  272. box-sizing: border-box;
  273. height: 30px;
  274. }
  275. .symptomPushTagList {
  276. border: 1px solid @icssBorder;
  277. }
  278. .symptomPushTagPool {
  279. height: 300px;
  280. overflow-y: auto;
  281. }
  282. .symptomPushOperationPoolPush {
  283. border: 1px dashed @icssBorder;
  284. }
  285. .hasSymptomPush {
  286. background: #abcdef;
  287. }
  288. .symptomPushTagItem {
  289. position: relative;
  290. line-height: 30px;
  291. cursor: pointer;
  292. padding: 0 10px;
  293. }
  294. .symptomPushOperationPool {
  295. position: relative;
  296. width: 30%;
  297. min-height: 300px;
  298. padding: 10px 0;
  299. float: left;
  300. }
  301. .symptomPushTagName:before {
  302. content: '['
  303. }
  304. .symptomPushTagName::after {
  305. content: ']'
  306. }
  307. .symptomPushBottomPartMid {
  308. width: 8%;
  309. margin-top: 60px;
  310. p {
  311. width: 100%;
  312. text-align: center;
  313. span {
  314. cursor: pointer;
  315. display: inline-block;
  316. width: 30px;
  317. height: 40px;
  318. line-height: 40px;
  319. margin: 0 auto;
  320. border: 1px solid @icssBorder;
  321. margin-bottom: 15px;
  322. font-size: 18px;
  323. }
  324. }
  325. }
  326. .symptomPushBottomPartRight {
  327. float: left;
  328. width: 60%;
  329. }
  330. .symptomPushButtonBox {
  331. width: 10%;
  332. float: left;
  333. }
  334. .symptomPushFollowButton {
  335. margin-top: 20px;
  336. }
  337. .symptomPushInputBox {
  338. width: 120px;
  339. .el-input {
  340. .el-input__inner {
  341. height: 30px;
  342. background: rgb(234, 231, 231);
  343. }
  344. }
  345. }
  346. .symptomPushTagItemPushBox {
  347. text-align: center
  348. }
  349. .symptomPushTagItemPush {
  350. display: inline-block;
  351. padding: 5px 10px;
  352. }
  353. .active {
  354. color: #aBcdef;
  355. }
  356. }
  357. </style>