index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :operation="operation()"
  6. :optionsEvensGroup="optionsEvensGroup"
  7. :columnParsing="columnParsing"
  8. :tableAttributes="tableAttributes"
  9. :tableEvents="tableEvents"
  10. :moreParameters="moreParameters"
  11. >
  12. <div class="cartographer_big">
  13. <el-dialog title="服务产品配置" width="100%" :modal="false" :visible.sync="formBool" :before-close="handleClose">
  14. <zj-page-container v-if="formBool">
  15. <zj-page-fill class="neibuview">
  16. <zj-form-container ref="formRef" :form-data="formData" :form-attributes="{ size: 'mini' }">
  17. <zj-form-module title="基本信息" label-width="120px" :form-data="formData" :form-items="formItems" />
  18. </zj-form-container>
  19. <el-card style="margin-top: 10px" size="mini">
  20. <div slot="header">
  21. <el-radio-group v-model="radio1" size="mini">
  22. <el-radio-button label="管理后台">管理后台</el-radio-button>
  23. <el-radio-button label="小程序">小程序</el-radio-button>
  24. </el-radio-group>
  25. </div>
  26. <zj-tree
  27. size="mini"
  28. v-show="radio1 == '管理后台'"
  29. :data="menus"
  30. :default-expand-all="true"
  31. :props="defaultProps"
  32. show-checkbox
  33. node-key="moduleId"
  34. ref="tree"
  35. highlight-current
  36. >
  37. </zj-tree>
  38. <zj-tree
  39. size="mini"
  40. v-show="radio1 == '小程序'"
  41. :data="minimenus"
  42. :default-expand-all="true"
  43. :props="defaultProps"
  44. show-checkbox
  45. node-key="moduleId"
  46. ref="tree22"
  47. highlight-current
  48. >
  49. </zj-tree>
  50. </el-card>
  51. </zj-page-fill>
  52. <div>
  53. <div style="box-sizing: border-box; padding: 10px; text-align: right">
  54. <el-button size="mini" @click="handleClose">取 消</el-button>
  55. <el-button size="mini" @click="formConfirm" type="primary">确 定</el-button>
  56. </div>
  57. </div>
  58. </zj-page-container>
  59. </el-dialog>
  60. </div>
  61. </template-page>
  62. </template>
  63. <script>
  64. import TemplatePage from '@/components/template/template-page-1.vue'
  65. import operation_mixin from '@/components/template/operation_mixin.js'
  66. import {
  67. serviceProductList,
  68. serviceProductAdd,
  69. serviceProductUpdate,
  70. serviceProductDelf
  71. } from '@/api/serviceProductConfig.js'
  72. import { getDataDictionary } from '@/api/dataDictionary.js'
  73. import { required } from '@/components/template/rules_verify.js'
  74. import { getMenuList } from '@/api/setting'
  75. import { getMenuList as getMenuList22 } from '@/api/miniMenus'
  76. import { mapGetters } from 'vuex'
  77. export default {
  78. components: {
  79. TemplatePage
  80. },
  81. mixins: [operation_mixin],
  82. data() {
  83. return {
  84. // 表单弹窗
  85. formBool: false,
  86. formData: {
  87. dictCode: '',
  88. dictType: '',
  89. dictValue: '',
  90. items: [],
  91. price: 0,
  92. remark: '',
  93. status: true
  94. },
  95. // 表格属性
  96. tableAttributes: {
  97. // 启用勾选列
  98. selectColumn: false
  99. },
  100. // 表格事件
  101. tableEvents: {
  102. 'selection-change': this.selectionChange
  103. },
  104. recordSelected: [],
  105. SERVICE_LABEL: [],
  106. defaultProps: {
  107. children: 'children',
  108. label: 'moduleName'
  109. },
  110. radio1: '管理后台',
  111. minimenus: [],
  112. menus: []
  113. }
  114. },
  115. computed: {
  116. ...mapGetters(['userid']),
  117. moreParameters() {
  118. return []
  119. },
  120. // 用户信息
  121. userInfo() {
  122. return JSON.parse(localStorage.getItem('greemall_user'))
  123. },
  124. // 事件组合
  125. optionsEvensGroup() {
  126. return [
  127. [
  128. [
  129. this.optionsEvensAuth('add', {
  130. click: () => {
  131. this.baseDataList()
  132. this.formBool = true
  133. }
  134. })
  135. ]
  136. ]
  137. ]
  138. },
  139. formItems() {
  140. return [
  141. {
  142. name: 'el-select',
  143. md: 8,
  144. options: this.SERVICE_LABEL,
  145. attributes: {
  146. placeholder: '请选择',
  147. clearable: true,
  148. filterable: true
  149. },
  150. formItemAttributes: {
  151. label: '产品服务',
  152. prop: 'dictCode',
  153. rules: [...required]
  154. }
  155. },
  156. {
  157. name: 'el-input',
  158. md: 8,
  159. attributes: {},
  160. formItemAttributes: {
  161. label: '销售价格(元)',
  162. prop: 'price',
  163. rules: [...required]
  164. }
  165. },
  166. {
  167. md: 8,
  168. name: 'el-radio',
  169. options: [
  170. { label: '开启', value: true },
  171. { label: '禁用', value: false }
  172. ],
  173. attributes: {},
  174. formItemAttributes: {
  175. label: '状态',
  176. prop: 'status',
  177. rules: [...required]
  178. }
  179. }
  180. ]
  181. }
  182. },
  183. methods: {
  184. // 列表请求函数
  185. getList: serviceProductList,
  186. // 列表导出函数
  187. // exportList: ,
  188. // 监听勾选变化
  189. selectionChange(data) {
  190. this.recordSelected = data
  191. },
  192. columnParsing(item, defaultData) {
  193. return defaultData
  194. },
  195. operation() {
  196. return this.operationBtn({
  197. edit: {
  198. click: ({ row, index, column }) => {
  199. this.baseDataList(() => {
  200. this.formBool = true
  201. serviceProductDelf({ id: row.id }).then(res => {
  202. var { items, ...p } = res.data
  203. this.$refs.tree.setCheckedKeys(
  204. items.filter(item => item.isWith === false && item.type === 'PC').map(item => item.moduleId)
  205. )
  206. this.$refs.tree22.setCheckedKeys(
  207. items.filter(item => item.isWith === false && item.type === 'WX').map(item => item.moduleId)
  208. )
  209. this.formData = { ...p }
  210. })
  211. })
  212. }
  213. }
  214. })
  215. },
  216. getchanpfw() {
  217. getDataDictionary({
  218. pageNum: 1,
  219. pageSize: -1,
  220. params: [
  221. { param: 'a.status', compare: '=', value: 'ON' },
  222. { param: 'a.dict_type', compare: '=', value: 'SERVICE_LABEL' }
  223. ]
  224. }).then(res => {
  225. this.SERVICE_LABEL = res.data.records.map(item => ({
  226. value: item.dictCode,
  227. label: item.dictValue
  228. }))
  229. })
  230. },
  231. handleClose(cb) {
  232. this.formBool = false
  233. this.$data.formData = this.$options.data().formData
  234. this.$refs?.pageRef?.refreshList()
  235. },
  236. formConfirm() {
  237. this.$refs.formRef.validate(valid => {
  238. if (valid) {
  239. ;(this.formData.id ? serviceProductUpdate : serviceProductAdd)({
  240. ...this.formData,
  241. items: [
  242. ...Array.from(new Set([...this.$refs.tree.getCheckedKeys()])).map(id => {
  243. return { moduleId: id, type: 'PC', isWith: false }
  244. }),
  245. ...Array.from(new Set([...this.$refs.tree.getHalfCheckedKeys()])).map(id => {
  246. return { moduleId: id, type: 'PC', isWith: true }
  247. }),
  248. ...Array.from(new Set([...this.$refs.tree22.getCheckedKeys()])).map(id => {
  249. return { moduleId: id, type: 'WX', isWith: false }
  250. }),
  251. ...Array.from(new Set([...this.$refs.tree22.getHalfCheckedKeys()])).map(id => {
  252. return { moduleId: id, type: 'WX', isWith: true }
  253. })
  254. ]
  255. }).then(res => {
  256. this.handleClose()
  257. this.$successMsg('配置成功')
  258. })
  259. }
  260. })
  261. },
  262. baseDataList(cb) {
  263. this.getchanpfw()
  264. // getCheckedKeys
  265. Promise.all([getMenuList({ adminUserId: this.userid }), getMenuList22({ adminUserId: this.userid })]).then(
  266. ([res, res2]) => {
  267. this.aaa(res.data)
  268. this.menus = res.data
  269. this.aaa(res2.data)
  270. this.minimenus = res2.data
  271. this.$nextTick(() => {
  272. cb?.()
  273. })
  274. }
  275. )
  276. },
  277. aaa(list) {
  278. for (var item of list) {
  279. if (item.type == 3) {
  280. item.tiling = true
  281. item.labelWidthNum = 115
  282. }
  283. if (item.children && item.children.length) {
  284. this.aaa(item.children)
  285. }
  286. }
  287. }
  288. }
  289. }
  290. </script>
  291. <style lang="scss" scoped>
  292. .neibuview {
  293. box-sizing: border-box;
  294. padding-left: 16px;
  295. ::v-deep & > .zj-page-fill-scroll {
  296. box-sizing: border-box;
  297. padding-right: 16px;
  298. & > div:nth-child(1) {
  299. margin-top: 20px;
  300. }
  301. }
  302. }
  303. </style>