index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :get-list="getList"
  5. :table-attributes="tableAttributes"
  6. :table-events="tableEvents"
  7. :options-evens-group="optionsEvensGroup"
  8. :moreParameters="moreParameters"
  9. :column-parsing="columnParsing"
  10. :operation="operation()"
  11. >
  12. <div class="cartographer_big">
  13. <el-dialog title="修改师傅数据" width="100%" :modal="false" :visible.sync="formDialog" :before-close="formCancel">
  14. <zj-page-container>
  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="100px" :form-data="formData" :form-items="formItems" />
  18. </zj-form-container>
  19. </zj-page-fill>
  20. <div style="box-sizing: border-box; padding: 16px; text-align: right !important">
  21. <el-button @click="formCancel" size="mini">取消</el-button>
  22. <el-button @click="formConfirm" type="primary" size="mini">确定</el-button>
  23. </div>
  24. </zj-page-container>
  25. </el-dialog>
  26. </div>
  27. </template-page>
  28. </template>
  29. <script>
  30. import TemplatePage from '@/components/template/template-page-1.vue'
  31. import import_mixin from '@/components/template/import_mixin.js'
  32. import ImageUpload from '@/components/file-upload'
  33. import { downloadFiles } from '@/utils/util'
  34. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  35. import { listPageV2, pageExport, del, listImport, memberUserWatitUpdate } from '@/api/workerProfileInit'
  36. import { commonTemplateDownload } from '@/api/common.js'
  37. import operation_mixin from '@/components/template/operation_mixin.js'
  38. export default {
  39. components: { TemplatePage, ImageUpload },
  40. mixins: [import_mixin, operation_mixin],
  41. data() {
  42. return {
  43. // 表格属性
  44. tableAttributes: {
  45. // 启用勾选列
  46. selectColumn: true
  47. },
  48. // 表格事件
  49. tableEvents: {
  50. 'selection-change': this.selectionChange
  51. },
  52. // 勾选选中行
  53. recordSelected: [],
  54. /** 表单变量 */
  55. formDialog: false,
  56. formData: {}
  57. }
  58. },
  59. computed: {
  60. // 事件组合
  61. optionsEvensGroup() {
  62. return [
  63. [
  64. [
  65. this.optionsEvensAuth('download', {
  66. click: () => {
  67. this.handleDownload()
  68. }
  69. })
  70. ],
  71. [
  72. this.optionsEvensAuth('import', {
  73. render: () => {
  74. return this.importButton(listImport, '导入师傅资料')
  75. }
  76. })
  77. ]
  78. ]
  79. ]
  80. },
  81. // 更多参数
  82. moreParameters() {
  83. return []
  84. },
  85. formItems() {
  86. return [
  87. {
  88. name: 'el-input',
  89. md: 6,
  90. attributes: {
  91. placeholder: '请输入'
  92. },
  93. formItemAttributes: {
  94. label: '名称',
  95. prop: 'name',
  96. rules: [...required]
  97. }
  98. },
  99. {
  100. name: 'el-input',
  101. md: 6,
  102. attributes: {
  103. placeholder: '请输入'
  104. },
  105. formItemAttributes: {
  106. label: '编号',
  107. prop: 'workerNumber',
  108. rules: [...required]
  109. }
  110. },
  111. {
  112. name: 'el-input',
  113. md: 6,
  114. attributes: {
  115. placeholder: '请输入'
  116. },
  117. formItemAttributes: {
  118. label: '身份证',
  119. prop: 'idcard',
  120. rules: [...required]
  121. }
  122. },
  123. {
  124. name: 'el-input',
  125. md: 6,
  126. attributes: {
  127. placeholder: '请输入'
  128. },
  129. formItemAttributes: {
  130. label: '手机号',
  131. prop: 'mobile',
  132. rules: [...required]
  133. }
  134. },
  135. {
  136. name: 'el-input',
  137. md: 6,
  138. attributes: {
  139. placeholder: '请输入'
  140. },
  141. formItemAttributes: {
  142. label: '银行卡号',
  143. prop: 'bankAccount',
  144. rules: []
  145. }
  146. }
  147. ]
  148. }
  149. },
  150. methods: {
  151. // 列表请求函数
  152. getList(p, cb) {
  153. try {
  154. var pam = JSON.parse(JSON.stringify(p))
  155. cb && cb(pam)
  156. return listPageV2(pam)
  157. } catch (error) {
  158. console.log(error)
  159. }
  160. },
  161. // 列表导出函数
  162. exportList: pageExport,
  163. // 表格列解析渲染数据更改
  164. columnParsing(item, defaultData) {
  165. return defaultData
  166. },
  167. // 监听勾选变化
  168. selectionChange(data) {
  169. this.recordSelected = data
  170. },
  171. // 表格操作列
  172. operation() {
  173. return this.operationBtn({
  174. del: {
  175. prompt: '确定删除吗?',
  176. click: ({ row, index, column }) => {
  177. del({
  178. id: row.id
  179. }).then(res => {
  180. if (res.code == 200) {
  181. this.$message({ type: 'success', message: `删除成功!` })
  182. this.$refs.pageRef.refreshList()
  183. } else {
  184. this.$message.error(res.msg)
  185. }
  186. })
  187. }
  188. },
  189. edit: {
  190. click: ({ row, index, column }) => {
  191. this.formData = { ...row }
  192. this.$nextTick(() => {
  193. this.openForm()
  194. })
  195. }
  196. }
  197. })
  198. },
  199. openForm() {
  200. this.formDialog = true
  201. },
  202. formCancel() {
  203. this.$refs?.formRef?.$refs?.inlineForm?.clearValidate?.()
  204. this.$data.formData = this.$options.data().formData
  205. this.formDialog = false
  206. },
  207. formConfirm() {
  208. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  209. if (valid) {
  210. memberUserWatitUpdate(this.formData).then(res => {
  211. this.$message({ type: 'success', message: `编辑成功!` })
  212. this.formCancel()
  213. this.$refs.pageRef.refreshList()
  214. })
  215. }
  216. })
  217. },
  218. handleDownload() {
  219. commonTemplateDownload({ name: '师傅资料初始化模板.xlsx' }, `${this.$route.meta.title}`)
  220. .then(res => {
  221. this.$message({
  222. message: '下载成功',
  223. type: 'success'
  224. })
  225. })
  226. .catch(err => {
  227. this.$message.error('下载失败')
  228. })
  229. }
  230. }
  231. }
  232. </script>
  233. <style lang="scss" scoped>
  234. .neibuview {
  235. box-sizing: border-box;
  236. padding-left: 16px;
  237. ::v-deep & > .zj-page-fill-scroll {
  238. box-sizing: border-box;
  239. padding-right: 16px;
  240. & > div:nth-child(1) {
  241. margin-top: 20px;
  242. }
  243. }
  244. }
  245. </style>