index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <template-page ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents"
  3. :operationColumnWidth="80" :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters"
  4. :column-parsing="columnParsing" :operation="operation" :exportList="exportList">
  5. <el-dialog title="" width="500px" custom-class="diy-dialog" append-to-body :modal="true" :visible.sync="formDialog"
  6. :show-close="true" :close-on-click-modal="false" :modal-append-to-body="false" :before-close="formCancel">
  7. <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
  8. <zj-form-module :title="formDialogTitles[formDialogType]" label-width="80px" :showPackUp="false"
  9. :form-data="formData" :form-items="formItems" :disabled="formDialogType == 2">
  10. </zj-form-module>
  11. </zj-form-container>
  12. <div slot="footer" class="dialog-footer">
  13. <el-button size="mini" @click="formCancel">取 消</el-button>
  14. <el-button size="mini" type="primary" @click="formConfirm()">确定</el-button>
  15. </div>
  16. </el-dialog>
  17. </template-page>
  18. </template>
  19. <script>
  20. import TemplatePage from '@/components/template/template-page-1.vue'
  21. import import_mixin from '@/components/template/import_mixin.js'
  22. import ImageUpload from '@/components/file-upload'
  23. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  24. import { listPageV2, pageExport, getDetail, add, edit, del } from "@/api/thirdPartyAddressLogin";
  25. import operation_mixin from '@/components/template/operation_mixin.js'
  26. export default {
  27. components: { TemplatePage, ImageUpload },
  28. mixins: [import_mixin, operation_mixin],
  29. data() {
  30. return {
  31. // 事件组合
  32. optionsEvensGroup: [
  33. [
  34. [
  35. {
  36. name: '新增',
  37. isRole: JSON.parse(localStorage.getItem('greemall_user')).userName == 'admin',
  38. click: this.addData
  39. }
  40. ],
  41. ],
  42. ],
  43. // 表格属性
  44. tableAttributes: {
  45. // 启用勾选列
  46. selectColumn: false
  47. },
  48. // 表格事件
  49. tableEvents: {
  50. 'selection-change': this.selectionChange
  51. },
  52. // 勾选选中行
  53. recordSelected: [],
  54. /** 表单变量 */
  55. formDialogType: 0,
  56. formDialogTitles: ["新增", "编辑", "详情"],
  57. formDialog: false,
  58. formData: {
  59. urlName: '',
  60. url: '',
  61. remark: '',
  62. status: 'ON',
  63. }
  64. }
  65. },
  66. computed: {
  67. // 更多参数
  68. moreParameters() {
  69. return []
  70. },
  71. formItems() {
  72. return [{
  73. md: 24,
  74. isShow: true,
  75. name: 'el-input',
  76. attributes: { placeholder: '请输入网址名称', },
  77. formItemAttributes: {
  78. label: '网址名称',
  79. prop: 'urlName',
  80. rules: [...required]
  81. }
  82. }, {
  83. md: 24,
  84. isShow: true,
  85. name: 'el-input',
  86. attributes: { placeholder: '请输入网址链接', },
  87. formItemAttributes: {
  88. label: '网址链接',
  89. prop: 'url',
  90. rules: [...required]
  91. }
  92. }, {
  93. md: 24,
  94. isShow: true,
  95. name: 'el-input',
  96. attributes: { placeholder: '请输入说明内容', type: "textarea", rows: 5 },
  97. formItemAttributes: {
  98. label: '说明',
  99. prop: 'remark',
  100. rules: [...required]
  101. }
  102. },{
  103. md: 24,
  104. isShow: true,
  105. name: 'slot-component',
  106. attributes: {},
  107. formItemAttributes: {
  108. label: '状态',
  109. prop: 'status',
  110. rules: [...required]
  111. },
  112. render: (h, { props, onInput }) => {
  113. var { value } = props
  114. return (
  115. <el-radio-group v-model={this.formData.status}>
  116. <el-radio label="ON">启用</el-radio>
  117. <el-radio label="OFF">禁用</el-radio>
  118. </el-radio-group>
  119. )
  120. }
  121. }]
  122. }
  123. },
  124. methods: {
  125. // 列表请求函数
  126. getList(p, cb) {
  127. try {
  128. var pam = JSON.parse(JSON.stringify(p))
  129. if(JSON.parse(localStorage.getItem('greemall_user')).userName != 'admin'){
  130. pam.params.push({ 'param': 'a.status', "compare": "=", "value": 'ON' })
  131. }
  132. cb && cb(pam)
  133. return listPageV2(pam)
  134. } catch (error) {
  135. console.log(error)
  136. }
  137. },
  138. // 列表导出函数
  139. exportList: pageExport,
  140. // 表格列解析渲染数据更改
  141. columnParsing(item, defaultData) {
  142. if(JSON.parse(localStorage.getItem('greemall_user')).userName != 'admin'){
  143. if (item.jname === 'url' || item.jname === 'status' || item.jname === 'createBy' || item.jname === 'createTime' || item.jname === 'updateBy' || item.jname === 'updateTime') {
  144. defaultData.hidden = true
  145. }
  146. if (item.jname === 'urlName') {
  147. console.log(defaultData)
  148. defaultData.render = (h, { row, index, column }) => {
  149. return (<el-link style="padding: 6px;" href={row.url} underline={false} target="_blank">{row.urlName}</el-link>)
  150. }
  151. }
  152. }
  153. return defaultData
  154. },
  155. // 监听勾选变化
  156. selectionChange(data) {
  157. this.recordSelected = data
  158. },
  159. // 表格操作列
  160. operation(h, { row, index, column }) {
  161. return (<div class='operation-btns'>
  162. {JSON.parse(localStorage.getItem('greemall_user')).userName == 'admin' ? <el-button type="text" onClick={() => {
  163. getDetail({
  164. id: row.id
  165. }).then(res => {
  166. Object.assign(this.formData, res.data)
  167. this.formDialogType = 1
  168. this.openForm()
  169. })
  170. }}>编辑</el-button> : null}
  171. {JSON.parse(localStorage.getItem('greemall_user')).userName == 'admin' ? <el-popconfirm
  172. title={`是否确定删除?`}
  173. onConfirm={() => {
  174. noticeDel({
  175. id: row.id
  176. }).then(res => {
  177. this.$message({
  178. type: 'success',
  179. message: '删除成功!'
  180. })
  181. this.$refs.pageRef.refreshList()
  182. })
  183. }}
  184. >
  185. <el-button type="text" slot="reference">删除</el-button>
  186. </el-popconfirm> : null}
  187. {JSON.parse(localStorage.getItem('greemall_user')).userName != 'admin' ? <el-button type="text" onClick={() => {
  188. window.open(row.url)
  189. }}>登陆</el-button> : null}
  190. </div>)
  191. },
  192. addData() {
  193. this.formDialogType = 0
  194. this.openForm()
  195. },
  196. openForm() {
  197. this.formDialog = true;
  198. },
  199. formCancel() {
  200. this.$refs.formRef.$refs.inlineForm.clearValidate()
  201. this.$data.formData = this.$options.data().formData
  202. this.formDialog = false
  203. },
  204. formConfirm() {
  205. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  206. if (valid) {
  207. ([add, edit][this.formDialogType])(this.formData).then(res => {
  208. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  209. this.formCancel()
  210. this.$refs.pageRef.refreshList()
  211. })
  212. }
  213. })
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. .tab {
  220. padding: 20px 20px 0 20px;
  221. }
  222. </style>