index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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="1200px" 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="100px" :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" v-if="formDialogType !== 2" 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 } from "@/api/auxiliaryFittings/supplier";
  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. tableAttributes: {
  33. // 启用勾选列
  34. selectColumn: false
  35. },
  36. // 表格事件
  37. tableEvents: {
  38. 'selection-change': this.selectionChange
  39. },
  40. // 勾选选中行
  41. recordSelected: [],
  42. /** 表单变量 */
  43. formDialogType: 0,
  44. formDialogTitles: ["新增", "编辑", "详情"],
  45. formDialog: false,
  46. formData: {
  47. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  48. venderName: '',
  49. linkName: '',
  50. linkTel: '',
  51. address: '',
  52. zipNo: '',
  53. email: '',
  54. www: '',
  55. telNo: '',
  56. corporation: '',
  57. faxNo: '',
  58. licenseId: '',
  59. khBank: '',
  60. bankRow: '',
  61. accNo: '',
  62. remark: '',
  63. status: 'ON',
  64. venderType: 'M',
  65. imageUrl: []
  66. }
  67. }
  68. },
  69. computed: {
  70. // 事件组合
  71. optionsEvensGroup() {
  72. return [
  73. [
  74. [
  75. this.optionsEvensAuth("add", {
  76. click: this.addData
  77. }),
  78. ]
  79. ]
  80. ]
  81. },
  82. // 更多参数
  83. moreParameters() {
  84. return []
  85. },
  86. formItems() {
  87. return [{
  88. md: 12,
  89. isShow: true,
  90. name: 'el-input',
  91. attributes: { placeholder: '请输入', disabled: true },
  92. formItemAttributes: {
  93. label: '所属商户',
  94. prop: 'companyName',
  95. rules: [...required]
  96. },
  97. }, {
  98. md: 12,
  99. isShow: true,
  100. name: 'slot-component',
  101. attributes: {},
  102. formItemAttributes: {
  103. label: '状态',
  104. prop: 'status',
  105. rules: [...required]
  106. },
  107. render: (h, { props, onInput }) => {
  108. var { value } = props
  109. return (
  110. <el-radio-group v-model={this.formData.status}>
  111. <el-radio disabled={this.formDialogType == 2} label="ON">启用</el-radio>
  112. <el-radio disabled={this.formDialogType == 2} label="OFF">禁用</el-radio>
  113. </el-radio-group>
  114. )
  115. }
  116. }, {
  117. md: 12,
  118. isShow: true,
  119. name: 'el-input',
  120. attributes: { placeholder: '请输入供应商名称', },
  121. formItemAttributes: {
  122. label: '供应商名称',
  123. prop: 'venderName',
  124. rules: [...required]
  125. }
  126. }, {
  127. md: 6,
  128. isShow: true,
  129. name: 'el-input',
  130. attributes: { placeholder: '请输入联系人' },
  131. formItemAttributes: {
  132. label: '联系人',
  133. prop: 'linkName',
  134. rules: [...required]
  135. }
  136. }, {
  137. md: 6,
  138. isShow: true,
  139. name: 'el-input',
  140. attributes: { placeholder: '请输入联系电话', maxlength: 11 },
  141. formItemAttributes: {
  142. label: '联系电话',
  143. prop: 'linkTel',
  144. rules: [...required, ...mobile]
  145. }
  146. }, {
  147. md: 12,
  148. isShow: true,
  149. name: 'slot-component',
  150. attributes: {},
  151. formItemAttributes: {
  152. label: '供应类型',
  153. prop: 'venderType',
  154. rules: [...required]
  155. },
  156. render: (h, { props, onInput }) => {
  157. var { value } = props
  158. return (
  159. <el-radio-group v-model={this.formData.venderType}>
  160. <el-radio disabled={this.formDialogType == 2} label="M">辅材</el-radio>
  161. <el-radio disabled={this.formDialogType == 2} label="P">配件</el-radio>
  162. <el-radio disabled={this.formDialogType == 2} label="A">辅材和配件</el-radio>
  163. </el-radio-group>
  164. )
  165. }
  166. }, {
  167. md: 12,
  168. isShow: true,
  169. name: 'el-input',
  170. attributes: { placeholder: '请输入地址' },
  171. formItemAttributes: {
  172. label: '地址',
  173. prop: 'address',
  174. rules: []
  175. }
  176. }, {
  177. md: 6,
  178. isShow: true,
  179. name: 'el-input',
  180. attributes: { placeholder: '请输入邮编' },
  181. formItemAttributes: {
  182. label: '邮编',
  183. prop: 'zipNo',
  184. rules: []
  185. }
  186. }, {
  187. md: 6,
  188. isShow: true,
  189. name: 'el-input',
  190. attributes: { placeholder: '请输入网址' },
  191. formItemAttributes: {
  192. label: '网址',
  193. prop: 'www',
  194. rules: [...httpUrl]
  195. }
  196. }, {
  197. md: 6,
  198. isShow: true,
  199. name: 'el-input',
  200. attributes: { placeholder: '请输入电子邮箱' },
  201. formItemAttributes: {
  202. label: '电子邮箱',
  203. prop: 'email',
  204. rules: [...email]
  205. }
  206. }, {
  207. md: 6,
  208. isShow: true,
  209. name: 'el-input',
  210. attributes: { placeholder: '请输入固定电话' },
  211. formItemAttributes: {
  212. label: '固定电话',
  213. prop: 'telNo',
  214. rules: []
  215. }
  216. }, {
  217. md: 6,
  218. isShow: true,
  219. name: 'el-input',
  220. attributes: { placeholder: '请输入传真' },
  221. formItemAttributes: {
  222. label: '传真',
  223. prop: 'faxNo',
  224. rules: []
  225. }
  226. }, {
  227. md: 6,
  228. isShow: true,
  229. name: 'el-input',
  230. attributes: { placeholder: '请输入法人名称' },
  231. formItemAttributes: {
  232. label: '法人',
  233. prop: 'corporation',
  234. rules: []
  235. }
  236. }, {
  237. md: 6,
  238. isShow: true,
  239. name: 'el-input',
  240. attributes: { placeholder: '请输入营业执照号' },
  241. formItemAttributes: {
  242. label: '营业执照号',
  243. prop: 'licenseId',
  244. rules: []
  245. }
  246. }, {
  247. md: 8,
  248. isShow: true,
  249. name: 'el-input',
  250. attributes: { placeholder: '请输入开户银行' },
  251. formItemAttributes: {
  252. label: '开户银行',
  253. prop: 'khBank',
  254. rules: []
  255. }
  256. }, {
  257. md: 8,
  258. isShow: true,
  259. name: 'el-input',
  260. attributes: { placeholder: '请输入开户行号' },
  261. formItemAttributes: {
  262. label: '开户行号',
  263. prop: 'bankRow',
  264. rules: []
  265. }
  266. }, {
  267. md: 8,
  268. isShow: true,
  269. name: 'el-input',
  270. attributes: { placeholder: '请输入银行账号' },
  271. formItemAttributes: {
  272. label: '银行账号',
  273. prop: 'accNo',
  274. rules: []
  275. }
  276. }, {
  277. md: 24,
  278. isShow: true,
  279. name: 'slot-component',
  280. formItemAttributes: {
  281. label: '营业执照',
  282. prop: 'imageUrl',
  283. rules: []
  284. },
  285. render: (h, { props, onInput }) => {
  286. var { value } = props
  287. return (
  288. <ImageUpload fileList={this.formData.imageUrl} limit={1} isEdit={this.formDialogType !== 2} />
  289. )
  290. }
  291. }, {
  292. md: 24,
  293. isShow: true,
  294. name: 'el-input',
  295. attributes: { placeholder: '请输入备注内容', type: "textarea", rows: 5 },
  296. formItemAttributes: {
  297. label: '备注',
  298. prop: 'remark',
  299. rules: []
  300. }
  301. }]
  302. }
  303. },
  304. methods: {
  305. // 列表请求函数
  306. getList(p) {
  307. try {
  308. var pam = JSON.parse(JSON.stringify(p))
  309. if (this.examineStatus) {
  310. pam.params.push({ "param": "b.examine_status", "compare": "=", "value": this.examineStatus })
  311. }
  312. return listPageV2(pam)
  313. } catch (error) {
  314. console.log(error)
  315. }
  316. },
  317. // 列表导出函数
  318. exportList: pageExport,
  319. // 表格列解析渲染数据更改
  320. columnParsing(item, defaultData) {
  321. if (item.jname === 'idCardImg') {
  322. defaultData.render = (h, { row, index, column }) => {
  323. return (
  324. <div style="padding:0 6px;cursor: pointer;">
  325. {row.idCardImg ? row.idCardImg.split(",").map(url => <el-image src={url} preview-src-list={[url]} fit="fit" style="width:80px;height:80px;" />) : null}
  326. </div>
  327. )
  328. }
  329. }
  330. return defaultData
  331. },
  332. // 监听勾选变化
  333. selectionChange(data) {
  334. this.recordSelected = data
  335. },
  336. operation() {
  337. return this.operationBtn({
  338. detail: {
  339. click: ({ row, index, column }) => {
  340. getDetail({ id: row.venderId }).then(res => {
  341. Object.assign(this.formData, res.data, {
  342. imageUrl: res.data?.imageUrl ? res.data?.imageUrl?.split(",").map(item => ({ url: item })) : []
  343. })
  344. this.formDialogType = 2
  345. this.openForm()
  346. })
  347. }
  348. },
  349. edit: {
  350. click: ({ row, index, column }) => {
  351. getDetail({ id: row.venderId }).then(res => {
  352. Object.assign(this.formData, res.data, {
  353. imageUrl: res.data?.imageUrl ? res.data?.imageUrl?.split(",").map(item => ({ url: item })) : []
  354. })
  355. console.log(this.formData)
  356. this.formDialogType = 1
  357. this.openForm()
  358. })
  359. }
  360. },
  361. })
  362. },
  363. addData() {
  364. this.formDialogType = 0
  365. this.openForm()
  366. },
  367. openForm() {
  368. this.formDialog = true;
  369. },
  370. formCancel() {
  371. this.$refs.formRef.$refs.inlineForm.clearValidate()
  372. this.$data.formData = this.$options.data().formData
  373. this.formDialog = false
  374. },
  375. formConfirm() {
  376. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  377. if (valid) {
  378. ([add, edit][this.formDialogType])({
  379. ...this.formData,
  380. imageUrl: this.formData.imageUrl.map(item => item.url).join(",")
  381. }).then(res => {
  382. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  383. this.formCancel()
  384. this.$refs.pageRef.refreshList()
  385. })
  386. }
  387. })
  388. }
  389. }
  390. }
  391. </script>
  392. <style lang="scss" scoped>
  393. .tab {
  394. padding: 20px 20px 0 20px;
  395. }
  396. </style>