selectforms.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. {extend name="common/common2" /}
  2. {block name="main"}
  3. <style>
  4. .disableFirstLevel .el-cascader-panel .el-scrollbar:first-child.el-checkbox {
  5. display: none;
  6. }
  7. </style>
  8. <div class="row" id="vue-plan">
  9. <div class="col-sm-12">
  10. <div class="ibox float-e-margins">
  11. <div class="ibox-content">
  12. <form method="post" action="{:url('add')}" class="form-horizontal">
  13. <div class="form-group">
  14. <label class="col-sm-2 control-label">检查项<span class="text-danger">*</span></label>
  15. <div class="col-sm-6">
  16. <el-cascader
  17. v-model="value"
  18. :options="options"
  19. :props="{ multiple: true }"
  20. clearable
  21. filterable
  22. size='small'
  23. collapse-tags
  24. @change="changeLabel"
  25. popper-class="disableFirstLevel"
  26. >
  27. </el-cascader>
  28. </div>
  29. </div>
  30. <input type="hidden" id="list">
  31. <div class="hr-line-dashed"></div>
  32. <div class="form-group">
  33. <div class="col-sm-6 col-sm-offset-2">
  34. <button class="btn btn-primary" id="bbb" onclick="saveSelect()" target-form="form-horizontal" type="button">确 定</button>
  35. </div>
  36. </div>
  37. </form>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. {/block}
  43. {block name="script"}
  44. <script>
  45. var idx = {$idx};
  46. var lists = [];
  47. var ids = localStorage.getItem("selectids")?JSON.parse(localStorage.getItem("selectids")):[];
  48. var vm = new Vue({
  49. el: '#vue-plan',
  50. data: function() {
  51. return {
  52. props: { multiple: true },
  53. options:{:json_encode($quality_cate)},
  54. value:[],
  55. shareScopeEnd: [],
  56. }
  57. },
  58. watch: {
  59. value(val){
  60. }
  61. },
  62. methods: {
  63. changeLabel(val) {
  64. // 是否与上次的类型相同
  65. let changeFlag = false
  66. let nowItem =[]
  67. let firstItem =[]
  68. if (this.shareScopeEnd.length == 0) {
  69. this.value = val
  70. } else {
  71. // 与原数组比对
  72. this.value.forEach((item) => {
  73. if (item[0] !== this.shareScopeEnd[0][0]) { // 一级标签不同
  74. changeFlag = true
  75. firstItem.push(item)
  76. }
  77. })
  78. }
  79. if (changeFlag && firstItem.length) {
  80. this.value=firstItem
  81. }
  82. this.shareScopeEnd = this.value
  83. var ll = [];
  84. this.shareScopeEnd.forEach((item) => {
  85. ll.push(item[2])
  86. })
  87. $("#list").val(ll.join(','));
  88. },
  89. }
  90. })
  91. function saveSelect() {
  92. var ll = $("#list").val();
  93. if(!ll){
  94. alert('未选择检查项')
  95. return false;
  96. }
  97. $.post('{:url("QualityForm/getCate")}',{id:ll},function (res) {
  98. ll = res.data;
  99. parent.layer.closeAll();
  100. parent.vm.selectForm(idx,ll);
  101. },'json')
  102. }
  103. </script>
  104. {/block}