index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :exportList="exportList"
  6. :columnParsing="columnParsing"
  7. :optionsEvensGroup="optionsEvensGroup"
  8. :tableAttributes="tableAttributes"
  9. :tableEvents="tableEvents"
  10. :operation="operation()"
  11. >
  12. <div class="cartographer_big">
  13. <el-dialog title="配置" width="100%" :modal="false" :visible.sync="formBool" :before-close="handleClose">
  14. <zj-page-container v-if="formBool">
  15. <zj-page-fill class="neibuview">
  16. <zj-form-container
  17. ref="formRef"
  18. :form-data="formData"
  19. :form-rules="formRules"
  20. :form-attributes="{ size: 'mini' }"
  21. >
  22. <zj-form-module title="上级网点信息" :form-data="formData" :form-items="items" />
  23. <zj-form-module title="下级网点信息" :form-data="formData" :form-items="items2" />
  24. </zj-form-container>
  25. </zj-page-fill>
  26. <!-- 操作按钮 -->
  27. <div style="box-sizing: border-box; padding: 10px; text-align: right">
  28. <el-button size="mini" @click="handleClose">取 消</el-button>
  29. <el-button v-if="~[0, 1].indexOf(formType)" size="mini" @click="formConfirm" type="primary"
  30. >确 定</el-button
  31. >
  32. </div>
  33. </zj-page-container>
  34. </el-dialog>
  35. </div>
  36. </template-page>
  37. </template>
  38. <script>
  39. import TemplatePage from '@/components/template/template-page-1.vue'
  40. import import_mixin from '@/components/template/import_mixin.js'
  41. import pagingTransfer from '@/components/paging-transfer.vue'
  42. import {
  43. settleRelaConfigList,
  44. settleRelaConfigListExport,
  45. settleRelaConfigAdd,
  46. settleRelaConfigEdit,
  47. settleRelaConfigDetail,
  48. settleRelaConfigQuerySubWebsit,
  49. settleRelaConfigImport
  50. } from '@/api/settlementRelationshipAllocation'
  51. import { commonTemplateDownload } from '@/api/common.js'
  52. import operation_mixin from '@/components/template/operation_mixin.js'
  53. import { required, requiredValueMin } from '@/components/template/rules_verify.js'
  54. import { getWebsit } from '@/api/customerManagement.js'
  55. import { EventBus } from '@/utils/eventBus'
  56. export default {
  57. components: { TemplatePage },
  58. mixins: [import_mixin, operation_mixin],
  59. data() {
  60. return {
  61. // 表格属性
  62. tableAttributes: {
  63. selectColumn: false
  64. },
  65. // 表格事件
  66. tableEvents: {
  67. 'selection-change': this.selectionChange
  68. },
  69. recordSelected: [],
  70. formBool: false,
  71. formType: 0,
  72. formData: {
  73. companyWechatId: '',
  74. companyWechatName: '',
  75. createBy: '',
  76. createTime: '',
  77. items: [],
  78. updateBy: '',
  79. updateTime: '',
  80. websitId: ''
  81. },
  82. formRules: {},
  83. websitList: [],
  84. formInline: {
  85. websitId: '',
  86. websitName: ''
  87. },
  88. itemsList: []
  89. }
  90. },
  91. computed: {
  92. optionsEvensGroup() {
  93. return [
  94. [
  95. [
  96. this.optionsEvensAuth('add', {
  97. click: () => {
  98. this.openWindow(() => {
  99. this.formType = 0
  100. this.formBool = true
  101. })
  102. }
  103. })
  104. ],
  105. [
  106. this.optionsEvensAuth('downloadImportTemplate', {
  107. click: () => {
  108. commonTemplateDownload({ name: '结算上下级关系配置模板.xlsx' }, `${this.$route.meta.title}`)
  109. .then(res => {
  110. this.$message({
  111. message: '下载成功',
  112. type: 'success'
  113. })
  114. })
  115. .catch(err => {
  116. this.$message.error('下载失败')
  117. })
  118. }
  119. })
  120. ],
  121. [
  122. this.optionsEvensAuth('import', ({ moduleName }) => {
  123. return {
  124. name: moduleName,
  125. render: () => {
  126. return this.importButton(settleRelaConfigImport, moduleName)
  127. }
  128. }
  129. })
  130. ]
  131. ]
  132. ]
  133. },
  134. items() {
  135. return [
  136. {
  137. name: 'el-select',
  138. md: 12,
  139. options: this.websitList.map(item => ({ label: item.name, value: item.websitId })),
  140. attributes: {
  141. clearable: true,
  142. filterable: true,
  143. disabled: false,
  144. placeholder: '请输入'
  145. },
  146. formItemAttributes: {
  147. label: '上级网点',
  148. prop: 'websitId',
  149. rules: [...required]
  150. },
  151. events: {
  152. change: val => {
  153. var data = this.websitList.find(item => item.websitId === val)
  154. this.formData.websitName = data?.name || ''
  155. }
  156. }
  157. },
  158. {
  159. name: 'slot-component',
  160. md: 12,
  161. attributes: {},
  162. formItemAttributes: {
  163. label: '',
  164. prop: '',
  165. rules: []
  166. },
  167. render: (h, { props, onInput }) => {
  168. return null
  169. }
  170. },
  171. {
  172. name: 'el-input',
  173. md: 6,
  174. attributes: {
  175. disabled: true,
  176. placeholder: '请输入'
  177. },
  178. formItemAttributes: {
  179. label: '创建人',
  180. prop: 'createBy'
  181. }
  182. },
  183. {
  184. name: 'el-input',
  185. md: 6,
  186. attributes: {
  187. disabled: true,
  188. placeholder: '请输入'
  189. },
  190. formItemAttributes: {
  191. label: '创建时间',
  192. prop: 'createTime'
  193. }
  194. },
  195. {
  196. name: 'el-input',
  197. md: 6,
  198. attributes: {
  199. disabled: true,
  200. placeholder: '请输入'
  201. },
  202. formItemAttributes: {
  203. label: '修改人',
  204. prop: 'updateBy'
  205. }
  206. },
  207. {
  208. name: 'el-input',
  209. md: 6,
  210. attributes: {
  211. disabled: true,
  212. placeholder: '请输入'
  213. },
  214. formItemAttributes: {
  215. label: '修改时间',
  216. prop: 'updateTime'
  217. }
  218. }
  219. ]
  220. },
  221. items2() {
  222. return [
  223. {
  224. name: 'slot-component',
  225. md: 24,
  226. attributes: {},
  227. formItemAttributes: { label: '', 'label-width': '0px', prop: 'items', rules: [...required] },
  228. render: (h, { props, onInput }) => {
  229. var { formData } = props
  230. return (
  231. <div>
  232. <div>
  233. <el-form
  234. size="mini"
  235. inline={true}
  236. value={this.formInline}
  237. onInput={v => {
  238. this.formInline = v
  239. }}
  240. label-width="0px"
  241. >
  242. <el-form-item label="">
  243. <el-input
  244. value={this.formInline.websitId}
  245. onInput={v => {
  246. this.formInline.websitId = v
  247. }}
  248. placeholder="网点编号"
  249. ></el-input>
  250. </el-form-item>
  251. <el-form-item label="">
  252. <el-input
  253. value={this.formInline.websitName}
  254. onInput={v => {
  255. this.formInline.websitName = v
  256. }}
  257. placeholder="网点名称"
  258. ></el-input>
  259. </el-form-item>
  260. <el-form-item>
  261. <el-button
  262. type="primary"
  263. onClick={() => {
  264. console.log(this)
  265. EventBus.$emit('handlePaginationCallBack')
  266. }}
  267. >
  268. 查询
  269. </el-button>
  270. <el-button
  271. onClick={() => {
  272. this.formInline.websitId = ''
  273. this.formInline.websitName = ''
  274. }}
  275. >
  276. 重置
  277. </el-button>
  278. </el-form-item>
  279. </el-form>
  280. </div>
  281. <pagingTransfer
  282. handlePaginationCallBackKey="handlePaginationCallBack"
  283. value={this.formData.items}
  284. onInput={v => {
  285. this.formData.items = v
  286. }}
  287. left-columns={[
  288. { id: 'belongCompanyCode', label: '所属公司编号', width: '160' },
  289. { id: 'websitId', label: '网点编号', width: '120' },
  290. { id: 'name', label: '网点名称', width: '' }
  291. ]}
  292. right-columns={[
  293. { id: 'belongCompanyCode', label: '所属公司编号', width: '160' },
  294. { id: 'websitId', label: '网点编号', width: '120' },
  295. { id: 'name', label: '网点名称', width: '' }
  296. ]}
  297. show-pagination={true}
  298. pagination-call-back={this.paginationCallback}
  299. title-texts={['待选项', '已选项']}
  300. min-height="300px"
  301. table-row-key={row => row.websitId}
  302. />
  303. </div>
  304. )
  305. }
  306. }
  307. ]
  308. }
  309. },
  310. methods: {
  311. // 列表请求函数
  312. getList: settleRelaConfigList,
  313. exportList: settleRelaConfigListExport,
  314. // 表格列解析渲染数据更改
  315. columnParsing(item, defaultData) {
  316. return defaultData
  317. },
  318. // 获取勾选框数据
  319. selectionChange(data) {
  320. this.recordSelected = data
  321. },
  322. handleClose() {
  323. this.$refs?.pageRef?.refreshList()
  324. this.$data.formData = this.$options.data().formData
  325. this.formType = 0
  326. this.formBool = false
  327. this.itemsList = []
  328. },
  329. formConfirm() {
  330. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  331. if (valid) {
  332. ;(this.formType ? settleRelaConfigEdit : settleRelaConfigAdd)(this.formData).then(res => {
  333. this.$message({ type: 'success', message: '配置成功!' })
  334. this.$refs.pageRef.refreshList()
  335. this.handleClose()
  336. })
  337. }
  338. })
  339. },
  340. operation() {
  341. return this.operationBtn({
  342. edit: {
  343. click: ({ row, index, column }) => {
  344. this.openWindow(() => {
  345. settleRelaConfigDetail({
  346. websitId: row.websitId
  347. }).then(res => {
  348. this.formData = { ...res.data, items: (res.data?.items || [])?.map(item => ({ ...item })) }
  349. this.itemsList = (this.formData?.items || [])?.map(item => ({ ...item }))
  350. this.$nextTick(() => {
  351. this.formType = 1
  352. this.formBool = true
  353. })
  354. })
  355. })
  356. }
  357. }
  358. })
  359. },
  360. openWindow(cb) {
  361. Promise.all([getWebsit({ type: 'C', status: true, queryPartsWebsit: true, level: 1 })]).then(([res1]) => {
  362. this.websitList = res1.data
  363. this.$nextTick(() => {
  364. cb?.()
  365. })
  366. })
  367. },
  368. paginationCallback({ pageIndex, pageSize }) {
  369. return new Promise(resolve => {
  370. settleRelaConfigQuerySubWebsit({ pageNum: pageIndex, pageSize: pageSize, ...this.formInline }).then(res => {
  371. resolve({
  372. total: res.data.total,
  373. data: [...this.itemsList, ...res.data.records]
  374. })
  375. })
  376. })
  377. }
  378. }
  379. }
  380. </script>
  381. <style lang="scss" scoped>
  382. .neibuview {
  383. box-sizing: border-box;
  384. padding-left: 16px;
  385. ::v-deep & > .zj-page-fill-scroll {
  386. box-sizing: border-box;
  387. padding-right: 16px;
  388. & > div:nth-child(1) {
  389. margin-top: 20px;
  390. }
  391. }
  392. }
  393. </style>