index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <zj-tab-page ref="tabPage" :defaultActives="[{ key: 'list', label: $route.meta.title + '-列表', essential: true }]">
  3. <template slot-scope="{ activeKey, data }">
  4. <div
  5. :style="{
  6. width: '100%',
  7. height: activeKey == 'list' ? '100%' : '0px',
  8. overflow: 'hidden'
  9. }"
  10. >
  11. <template-page
  12. ref="pageRef"
  13. :get-list="getList"
  14. :table-attributes="tableAttributes"
  15. :table-events="tableEvents"
  16. :options-evens-group="optionsEvensGroup"
  17. :moreParameters="moreParameters"
  18. :column-parsing="columnParsing"
  19. :exportList="exportList"
  20. :operation="operation()"
  21. >
  22. </template-page>
  23. </div>
  24. <div v-if="~['add', 'edit'].indexOf(activeKey)">
  25. <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
  26. <zj-form-module
  27. title=""
  28. label-width="110px"
  29. :showPackUp="false"
  30. :form-data="formData"
  31. :form-items="formItems"
  32. >
  33. </zj-form-module>
  34. </zj-form-container>
  35. <div slot="footer" class="dialog-footer">
  36. <el-button size="mini" @click="data.removeTab()">取 消</el-button>
  37. <el-button size="mini" @click="formConfirm(data.removeTab)" type="primary">确 定</el-button>
  38. </div>
  39. </div>
  40. </template>
  41. </zj-tab-page>
  42. </template>
  43. <script>
  44. import TemplatePage from '@/components/template/template-page-1.vue'
  45. import import_mixin from '@/components/template/import_mixin.js'
  46. import ImageUpload from '@/components/file-upload'
  47. import operation_mixin from '@/components/template/operation_mixin.js'
  48. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  49. import {
  50. dailyBankList,
  51. dailyBankListExport,
  52. dailyBankTemplateImport,
  53. dailyBankDelete,
  54. dailyBankAdd,
  55. dailyBankUpdate,
  56. dailyBankDetail
  57. } from '@/api/bankAccount'
  58. import { commonTemplateDownload } from '@/api/common.js'
  59. export default {
  60. components: { TemplatePage, ImageUpload },
  61. mixins: [import_mixin, operation_mixin],
  62. data() {
  63. return {
  64. // 表格属性
  65. tableAttributes: {
  66. // 启用勾选列
  67. selectColumn: false
  68. },
  69. // 表格事件
  70. tableEvents: {
  71. 'selection-change': this.selectionChange
  72. },
  73. // 勾选选中行
  74. recordSelected: [],
  75. // 表单
  76. formData: {
  77. bankAccount: '',
  78. bankAccountName: '',
  79. bankAddr: '',
  80. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  81. companyWechatId: '',
  82. depositBank: '',
  83. idcard: '',
  84. mobile: '',
  85. remark: '',
  86. websitId: '',
  87. websitName: '',
  88. workerName: '',
  89. workerNumber: ''
  90. }
  91. }
  92. },
  93. computed: {
  94. // 更多参数
  95. moreParameters() {
  96. return []
  97. },
  98. optionsEvensGroup() {
  99. return [
  100. [
  101. [
  102. this.optionsEvensAuth('add', {
  103. click: () => {
  104. this.close()
  105. this.$refs.tabPage.addTab({
  106. // 对应显示的模块
  107. activeKey: 'add',
  108. // 唯一标识
  109. key: 'add',
  110. // 页签名称
  111. label: '新增',
  112. // 打开时事件
  113. triggerEvent: () => {},
  114. // 关闭时事件
  115. closeEvent: () => {}
  116. })
  117. }
  118. })
  119. ]
  120. ],
  121. [
  122. [
  123. this.optionsEvensAuth('import', ({ moduleName }) => {
  124. return {
  125. name: moduleName,
  126. render: () => {
  127. return this.importButton(dailyBankTemplateImport, moduleName)
  128. }
  129. }
  130. })
  131. ]
  132. ],
  133. [
  134. [
  135. this.optionsEvensAuth('template', {
  136. click: () => {
  137. commonTemplateDownload({ name: '银行账户模板.xlsx' }, `银行账户模板`)
  138. .then(res => {
  139. this.$message({
  140. message: '下载成功',
  141. type: 'success'
  142. })
  143. })
  144. .catch(err => {
  145. this.$message.error('下载失败')
  146. })
  147. }
  148. })
  149. ]
  150. ]
  151. ]
  152. },
  153. formItems() {
  154. return [
  155. {
  156. name: 'el-input',
  157. md: 6,
  158. attributes: {
  159. disabled: false
  160. },
  161. formItemAttributes: {
  162. label: '师傅名称',
  163. prop: 'workerName',
  164. rules: [...required]
  165. }
  166. },
  167. {
  168. name: 'el-input',
  169. md: 6,
  170. attributes: {
  171. disabled: false
  172. },
  173. formItemAttributes: {
  174. label: '身份证',
  175. prop: 'idcard',
  176. rules: [...required]
  177. }
  178. },
  179. {
  180. name: 'el-input',
  181. md: 6,
  182. attributes: {
  183. disabled: false
  184. },
  185. formItemAttributes: {
  186. label: '联系电话',
  187. prop: 'mobile',
  188. rules: [...mobileRequired]
  189. }
  190. },
  191. {
  192. name: 'el-input',
  193. md: 6,
  194. attributes: {
  195. disabled: false
  196. },
  197. formItemAttributes: {
  198. label: '银行卡',
  199. prop: 'bankAccount',
  200. rules: [...required]
  201. }
  202. },
  203. {
  204. name: 'el-input',
  205. md: 6,
  206. attributes: {
  207. disabled: false
  208. },
  209. formItemAttributes: {
  210. label: '户名',
  211. prop: 'bankAccountName',
  212. rules: [...required]
  213. }
  214. },
  215. {
  216. name: 'el-input',
  217. md: 6,
  218. attributes: {
  219. disabled: false
  220. },
  221. formItemAttributes: {
  222. label: '开户行名称',
  223. prop: 'depositBank',
  224. rules: [...required]
  225. }
  226. },
  227. {
  228. name: 'el-input',
  229. md: 12,
  230. attributes: {
  231. disabled: false
  232. },
  233. formItemAttributes: {
  234. label: '开户行地址',
  235. prop: 'bankAddr',
  236. rules: []
  237. }
  238. },
  239. {
  240. name: 'el-input',
  241. md: 24,
  242. attributes: {
  243. disabled: false,
  244. type: 'textarea',
  245. rows: 2
  246. },
  247. formItemAttributes: {
  248. label: '备注',
  249. prop: 'remark',
  250. rules: []
  251. }
  252. }
  253. ]
  254. }
  255. },
  256. methods: {
  257. // 列表请求函数
  258. getList(p, cb) {
  259. try {
  260. cb && cb(p)
  261. return dailyBankList(p)
  262. } catch (error) {
  263. console.log(error)
  264. }
  265. },
  266. // 列表导出函数
  267. exportList: dailyBankListExport,
  268. // 表格列解析渲染数据更改
  269. columnParsing(item, defaultData) {
  270. return defaultData
  271. },
  272. // 监听勾选变化
  273. selectionChange(data) {
  274. this.recordSelected = data
  275. },
  276. operation() {
  277. return this.operationBtn({
  278. edit: {
  279. click: ({ row, index, column }) => {
  280. this.close()
  281. dailyBankDetail({ id: row.id }).then(res => {
  282. this.formData = res.data
  283. this.$refs.tabPage.addTab({
  284. // 对应显示的模块
  285. activeKey: 'edit',
  286. // 唯一标识
  287. key: 'edit',
  288. // 页签名称
  289. label: '编辑',
  290. // 打开时事件
  291. triggerEvent: () => {},
  292. // 关闭时事件
  293. closeEvent: () => {}
  294. })
  295. })
  296. }
  297. },
  298. del: {
  299. prompt: '确定删除吗?',
  300. click: ({ row, index, column }) => {
  301. dailyBankDelete({ id: row.id }).then(res => {
  302. this.$message({
  303. type: 'success',
  304. message: '删除成功!'
  305. })
  306. this.$refs?.pageRef?.refreshList()
  307. })
  308. }
  309. }
  310. })
  311. },
  312. formConfirm(removeTab) {
  313. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  314. if (valid) {
  315. ;(this.formData.id ? dailyBankUpdate : dailyBankAdd)({
  316. ...this.formData
  317. }).then(res => {
  318. this.$message({ type: 'success', message: `设置成功!` })
  319. this.$refs?.pageRef?.refreshList()
  320. removeTab()
  321. })
  322. }
  323. })
  324. },
  325. close() {
  326. this.$data.formData = this.$options.data().formData
  327. }
  328. }
  329. }
  330. </script>
  331. <style lang="scss" scoped></style>