SymptomPush.vue 13 KB

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