TemplateMaintenanceWrap.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <div class="NoiseTemplateWrapper TemplateWrapper">
  3. <crumbs
  4. :title="txt"
  5. class="topBack"
  6. linkTo="/admin/LT-YXSJWH-MBWH"
  7. ></crumbs>
  8. <PubTemplateGroup
  9. :editData="editData"
  10. @changeVal="changeVal"
  11. @validatePass="validatePass"
  12. @staticOwn="staticOwn"
  13. ref="submitForm"
  14. ></PubTemplateGroup>
  15. <div class="main">
  16. <CommonTemplate
  17. v-if="dataPub.region1"
  18. :pool="dataPub.tagPool"
  19. :type="dataPub.region1"
  20. :signe="dataPub.region3"
  21. :rela="dataPub.region4"
  22. :options="editData"
  23. @changeActionData="changeActionData"
  24. >
  25. </CommonTemplate>
  26. <div class="btn">
  27. <el-button
  28. type="primary"
  29. :disabled="dataPub.isCopy && staticOwnTo == dataPub.region4"
  30. :plain="dataPub.isCopy && staticOwnTo == dataPub.region4"
  31. @click="submitForm"
  32. >确 定</el-button>
  33. </div>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. /**
  39. * dataPub.region2 判断底部显示哪些
  40. */
  41. import PubTemplateGroup from './PubTemplateGroup';
  42. import CommonTemplate from './CommonTemplate';
  43. import api from '@api/icss.js';
  44. import utils from '@api/utils.js';
  45. export default {
  46. name: 'TemplateMaintenanceWrap',
  47. data() {
  48. return {
  49. txt:'模板维护-添加模板',
  50. dataPub: {}, //公用组件传的值都在这
  51. editData:{}, //编辑数据
  52. sendIds: [], //标签明细右侧操作数据
  53. staticOwnTo:''
  54. }
  55. },
  56. beforeMount:function(){
  57. const {isEdit,data} = this.$route.params;
  58. if(isEdit){
  59. this.txt = '模板维护-修改模板';
  60. this.editData = data;
  61. // console.log('回读数据', this.editData)
  62. }
  63. },
  64. methods: {
  65. back() { this.$router.go(-1) },
  66. staticOwn(val){
  67. console.log(val,'change555')
  68. this.staticOwnTo = val
  69. },
  70. changeVal(val) { //子组件数据改变传递到父组件
  71. this.dataPub = val // console.log('公用组件传的值都在这', val)
  72. if(val.isCopy){
  73. this.txt = '模板维护-复制模板'
  74. }
  75. },
  76. changeActionData(arr) { //标签明细右侧数据id
  77. this.sendIds = arr
  78. },
  79. submitForm() { // 调用子组件的方法验证公用部分
  80. this.$refs.submitForm.submitForm('groups');
  81. },
  82. validatePass() { //验证成功回调,调取接口
  83. //仍需验证标签明细是否选择
  84. let type = this.dataPub.region1,name=this.dataPub.region2;
  85. let detailLis = utils.orderTemplateData(this.sendIds)
  86. if (JSON.stringify(this.sendIds) == '[]' || !detailLis) {
  87. this.$message({
  88. message: '模板至少包含一个标签池标签',
  89. type: 'warning'
  90. });
  91. return;
  92. }else if(detailLis[0].questionId == '' && detailLis.length == 1){
  93. this.$message({
  94. message: '保存模版时,无法保存单独的输入栏',
  95. type: 'warning'
  96. });
  97. return;
  98. }
  99. let param = {
  100. "modelDetils": detailLis,
  101. "name": name,
  102. "type": type,
  103. "flag": (type == 322 || type == 32 || type == 31)?3:'',
  104. "textType": type,
  105. "id":this.editData.id || '',
  106. "moduleType": this.dataPub.region3,
  107. "relationId": this.dataPub.region4
  108. }
  109. // console.log(param,'保存模板的参数')
  110. this.showDelDialog(param)
  111. },
  112. showDelDialog(param) {
  113. this.showConfirmDialog('是否保存该模板?', () => {
  114. if(this.editData.id){
  115. api.updateModuleInfo(param).then((res) => {
  116. if (res.data.code === '0') {
  117. this.warning(res.data.msg || '修改成功', 'success','1000')
  118. setTimeout(() => {
  119. this.$router.push({
  120. path:'/admin/LT-YXSJWH-MBWH'
  121. })
  122. }, 1000);
  123. } else {
  124. this.warning(res.data.msg)
  125. }
  126. }).catch((err) => {
  127. this.warning(err);
  128. })
  129. }else{
  130. api.saveModuleInfo(param).then((res) => {
  131. if (res.data.code === '0') {
  132. this.warning(res.data.msg || '保存成功', 'success','1000')
  133. setTimeout(() => {
  134. this.$router.push({
  135. path:'/admin/LT-YXSJWH-MBWH'
  136. })
  137. }, 1000);
  138. } else {
  139. this.warning(res.data.msg)
  140. }
  141. }).catch((err) => {
  142. this.warning(err);
  143. })
  144. }
  145. });
  146. },
  147. showConfirmDialog(msg, resolve) {
  148. this.$alert(msg, '提示', {
  149. confirmButtonText: '确定',
  150. type: 'warning'
  151. }).then(() => {
  152. resolve();
  153. }).catch(() => {});
  154. },
  155. warning(msg, type,time) {
  156. this.$message({
  157. showClose: true,
  158. message: msg,
  159. type: type || 'warning',
  160. duration:time || '3000'
  161. })
  162. },
  163. },
  164. components: {
  165. PubTemplateGroup,
  166. CommonTemplate,
  167. }
  168. }
  169. </script>
  170. <style lang="less">
  171. @import "../../less/common.less";
  172. .NoiseTemplateWrapper {
  173. .groupTitle {
  174. background-color: #fff;
  175. height: 40px;
  176. line-height: 40px;
  177. padding-left: 20px;
  178. }
  179. .main {
  180. background-color: #fff;
  181. margin: 0 20px 20px;
  182. padding: 20px;
  183. border-top: 1px solid @icssBorder;
  184. box-sizing: border-box;
  185. font-size: 14px;
  186. color: #606266;
  187. .title {
  188. margin-bottom: 20px;
  189. i {
  190. color: #f56c6c;
  191. }
  192. }
  193. }
  194. .btn {
  195. text-align: right;
  196. }
  197. .order {
  198. margin-bottom: 20px;
  199. .el-input__inner {
  200. line-height: 30px;
  201. height: 30px;
  202. }
  203. }
  204. }
  205. </style>