index.vue 12 KB

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