index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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: listPageV2,
  127. // 列表导出函数
  128. exportList: pageExport,
  129. // 表格列解析渲染数据更改
  130. columnParsing(item, defaultData) {
  131. return defaultData
  132. },
  133. // 监听勾选变化
  134. selectionChange(data) {
  135. this.recordSelected = data
  136. },
  137. // 表格操作列
  138. operation(h, { row, index, column }) {
  139. return (<div class='operation-btns'>
  140. {JSON.parse(localStorage.getItem('greemall_user')).userName == 'admin' ? <el-button type="text" onClick={() => {
  141. getDetail({
  142. id: row.id
  143. }).then(res => {
  144. Object.assign(this.formData, res.data)
  145. this.formDialogType = 1
  146. this.openForm()
  147. })
  148. }}>编辑</el-button> : null}
  149. {JSON.parse(localStorage.getItem('greemall_user')).userName == 'admin' ? <el-popconfirm
  150. title={`是否确定删除?`}
  151. onConfirm={() => {
  152. noticeDel({
  153. id: row.id
  154. }).then(res => {
  155. this.$message({
  156. type: 'success',
  157. message: '删除成功!'
  158. })
  159. this.$refs.pageRef.refreshList()
  160. })
  161. }}
  162. >
  163. <el-button type="text" slot="reference">删除</el-button>
  164. </el-popconfirm> : null}
  165. {JSON.parse(localStorage.getItem('greemall_user')).userName != 'admin' ? <el-button type="text" onClick={() => {
  166. window.open(row.url)
  167. }}>登陆</el-button> : null}
  168. </div>)
  169. },
  170. addData() {
  171. this.formDialogType = 0
  172. this.openForm()
  173. },
  174. openForm() {
  175. this.formDialog = true;
  176. },
  177. formCancel() {
  178. this.$refs.formRef.$refs.inlineForm.clearValidate()
  179. this.$data.formData = this.$options.data().formData
  180. this.formDialog = false
  181. },
  182. formConfirm() {
  183. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  184. if (valid) {
  185. ([add, edit][this.formDialogType])(this.formData).then(res => {
  186. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  187. this.formCancel()
  188. this.$refs.pageRef.refreshList()
  189. })
  190. }
  191. })
  192. }
  193. }
  194. }
  195. </script>
  196. <style lang="scss" scoped>
  197. .tab {
  198. padding: 20px 20px 0 20px;
  199. }
  200. </style>