Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

index.vue 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. <template>
  2. <div>
  3. <crud-template ref="crudRef" class="as-weight" :submit-state="false" :home-data="field" :tableData="tableData"
  4. @btnSearch="btnSearch" @CurrentChange="handleCurrentChange" @importData="importData" @refreshLeft="refreshLeft"
  5. @add="handleAdd" @cancel="cancel">
  6. <template #search>
  7. <el-input maxlength="60" v-trim clearable v-model="searchForm.name" style="width: 200px"
  8. placeholder="请输入网点名称" />
  9. <el-input maxlength="60" v-trim clearable v-model="searchForm.serviceHallId" style="width: 200px"
  10. placeholder="请输入网点编号" />
  11. <el-input maxlength="60" v-trim clearable v-model="searchForm.agencyId" style="width: 200px"
  12. placeholder="请输入渠道编号" />
  13. </template>
  14. <template #CustomButton>
  15. <!-- <el-button v-if="IsPermission(route, 'ADD_FIRST_DOT')" type="primary" @click="handleFirstDot" icon="Plus">
  16. 添加一级网点
  17. </el-button> -->
  18. <el-button type="success" @click="getItmeLiet()">
  19. 中心网点管理
  20. </el-button>
  21. </template>
  22. <template #operation="{ scope }">
  23. <el-button v-if="IsPermission(route, 'EDIT_LIST')" type="primary" @click="handleEdit(scope.row)" size="small">
  24. 编辑
  25. </el-button>
  26. <!-- <el-button v-if="IsPermission(route, 'EDIT_LIST')" type="primary" @click="handleImport(scope.row)" size="small">
  27. 导入
  28. </el-button> -->
  29. <el-upload style="display: inline-block; margin: 0 10px;vertical-align: middle;" ref="upload" :data="data"
  30. :action="uploadUrl" :on-success="handleAvatarSuccess" accept=".xls, .xlsx" :limit="1"
  31. :on-exceed="handleExceed" :show-file-list="false" :multiple="false">
  32. <el-button type="primary" class="btn" icon="Upload" @click="handleImport(scope.row)" size="small">
  33. 导入
  34. </el-button>
  35. </el-upload>
  36. <el-button v-if="IsPermission(route, 'EDIT_LIST')" type="primary" @click="handleFileName()" size="small">
  37. 下载模板
  38. </el-button>
  39. <el-button v-if="IsPermission(route, 'DEL_LIST')" :type="scope.row.state==='ENABLE'?'danger':'success'" @click="handleDetele(scope.row)" size="small">
  40. {{ scope.row.state === 'ENABLE' ? '禁用' : '启用' }}
  41. </el-button>
  42. </template>
  43. <template #dialog>
  44. <el-form label-position="right" label-width="150px" :model="addForm" :rules="rules"
  45. :ref="(el) => (dataFormRef = el)" :hide-required-asterisk="typeOption === 'view'" v-loading="formLoding">
  46. <el-form-item v-if="!isFirstDot" label="上级网点:" prop="superServiceHallId">
  47. <div style="width: 100%">
  48. <el-tree-select :load="load" lazy filterable style="width: 100%" placeholder="请选择上级网点编号"
  49. v-model="addForm.superServiceHallId" :props="{
  50. label: 'servicehallName',
  51. children: 'childrens',
  52. value: 'servicehallId',
  53. isLeaf: 'isLeaf',
  54. }" value-key="servicehallId" :check-strictly="true" :render-after-expand="false"
  55. node-key="servicehallId" show-checkbox />
  56. </div>
  57. </el-form-item>
  58. <el-form-item label="网点编号:" prop="serviceHallId">
  59. <div style="width: 100%">
  60. <el-input maxlength="60" v-trim clearable v-model="addForm.serviceHallId" placeholder="请输入网点编号" />
  61. </div>
  62. </el-form-item>
  63. <el-form-item label="网点名称:" prop="name">
  64. <div style="width: 100%">
  65. <el-input maxlength="60" v-trim clearable v-model="addForm.name" placeholder="请输入网点名称" />
  66. </div>
  67. </el-form-item>
  68. <el-form-item label="中心网点编号:" prop="mapChannelId">
  69. <div style="width: 100%">
  70. <el-select clearable filterable v-model="addForm.mapChannelId" style="width: 100%"
  71. @change="centerServiceHallIdChange" placeholder="请选择中心网点编号">
  72. <el-option v-for="item in centerServiceHallIdList" :key="item.centerServiceHallId" :label="item.centerServicehallName"
  73. :value="item.centerServiceHallId" />
  74. </el-select>
  75. </div>
  76. </el-form-item>
  77. <el-form-item label="地址:" prop="address">
  78. <div style="width: 100%">
  79. <el-input maxlength="60" v-trim clearable v-model="addForm.address" placeholder="请输入地址" />
  80. </div>
  81. </el-form-item>
  82. <el-form-item label="联系人电话:" prop="tel">
  83. <div style="width: 100%">
  84. <el-input maxlength="60" v-trim clearable v-model="addForm.tel" placeholder="请输入联系人电话" />
  85. </div>
  86. </el-form-item>
  87. <el-form-item label="联系人:" prop="contact">
  88. <div style="width: 100%">
  89. <el-input maxlength="60" v-trim clearable v-model="addForm.contact" placeholder="请输入联系人" />
  90. </div>
  91. </el-form-item>
  92. <el-form-item label="经度:" prop="longitude">
  93. <div style="width: 100%">
  94. <el-input maxlength="60" v-trim clearable v-model="addForm.longitude" placeholder="请输入经度" />
  95. </div>
  96. </el-form-item>
  97. <el-form-item label="纬度:" prop="latitude">
  98. <div style="width: 100%">
  99. <el-input maxlength="60" v-trim clearable v-model="addForm.latitude" placeholder="请输入纬度" />
  100. </div>
  101. </el-form-item>
  102. <el-form-item label="半径距离(单位:米):" prop="radial">
  103. <div style="width: 100%">
  104. <el-input maxlength="60" v-trim clearable v-model="addForm.radial" placeholder="请输入半径距离(单位:米)" />
  105. </div>
  106. </el-form-item>
  107. <el-form-item label="所属渠道:" prop="agencyId">
  108. <div style="width: 100%">
  109. <el-select clearable filterable v-model="addForm.agencyId" style="width: 100%" @change="agencyIdChange"
  110. placeholder="请选择所属渠道">
  111. <el-option v-for="item in agencyList" :key="item.value" :label="item.label" :value="item.value" />
  112. </el-select>
  113. </div>
  114. </el-form-item>
  115. <el-form-item label="渠道编号:" prop="agencyId">
  116. <div style="width: 100%">
  117. <el-select clearable filterable v-model="addForm.agencyId" style="width: 100%" placeholder="请选择所属渠道"
  118. :disabled="true">
  119. <el-option v-for="item in agencyList" :key="item.value" :label="item.value" :value="item.value" />
  120. </el-select>
  121. </div>
  122. </el-form-item>
  123. </el-form>
  124. <div style="padding: 0 0 30px 0;text-align: right;">
  125. <el-button type="success" icon="Plus" @click="addBtn" style="margin-bottom: 10px;">
  126. 添加
  127. </el-button>
  128. <div style="padding: 20px 50px;text-align: left;font-weight: 700;" v-if="addForm.locationModels.length > 0">
  129. 办理点信息</div>
  130. <el-form v-for="(item, index) in addForm.locationModels" :key="index" label-width="150" :rules="rules" :model="item">
  131. <el-form-item label="名称:" prop="name">
  132. <div style="width: 100%">
  133. <el-input maxlength="60" v-trim clearable v-model="item.name" placeholder="请输入办理点名称" />
  134. </div>
  135. </el-form-item>
  136. <el-form-item label="地址:" prop="address">
  137. <div style="width: 100%">
  138. <el-input maxlength="60" v-trim clearable v-model="item.address" placeholder="请输入地址" />
  139. </div>
  140. </el-form-item>
  141. <el-form-item label="经度:" prop="longitude">
  142. <div style="width: 100%">
  143. <el-input maxlength="60" v-trim clearable v-model="item.longitude" placeholder="请输入经度" />
  144. </div>
  145. </el-form-item>
  146. <el-form-item label="纬度:" prop="latitude">
  147. <div style="width: 100%">
  148. <el-input maxlength="60" v-trim clearable v-model="item.latitude" placeholder="请输入纬度" />
  149. </div>
  150. </el-form-item>
  151. <el-form-item label="半径距离(单位:米):" prop="radial">
  152. <div style="width: 100%">
  153. <el-input maxlength="60" v-trim clearable v-model="item.radial" placeholder="请输入半径距离(单位:米)" />
  154. </div>
  155. </el-form-item>
  156. <el-button class="op-btn" type="danger" @click="deleteHandle(index)">
  157. 删除
  158. </el-button>
  159. </el-form>
  160. </div>
  161. </template>
  162. <template #footer>
  163. <el-button type="default" @click="cancel" v-if="typeOption !== 'view'">
  164. 取消
  165. </el-button>
  166. <el-button type="primary" @click="submitHandle()" v-if="typeOption !== 'view'">
  167. 确定
  168. </el-button>
  169. </template>
  170. </crud-template>
  171. <el-dialog title="中心网点管理" v-model="vShowDoalog">
  172. <crud-template ref="crudRefTwo" :home-data="zxqdFind" @submit="itemAdd" @handleEdit="itemEdit" @add="Adds"
  173. :searchForm="searchForm" @CurrentChange="handleCurrentChangeTwo" @handleDelete="itemDelete"
  174. :tableData="tableItemData">
  175. </crud-template>
  176. </el-dialog>
  177. </div>
  178. </template>
  179. <script setup lang="ts">
  180. import { ref, reactive, toRaw, onMounted, computed } from 'vue'
  181. // @ts-ignore crudFrom模板
  182. import CrudTemplate from '@/crud/index.vue'
  183. import BaseService from '@/utils/baseService' //引入接口请求
  184. import {
  185. ElMessage, ElMessageBox, UploadInstance, UploadProps,
  186. UploadRawFile,
  187. genFileId,
  188. } from 'element-plus' //提示
  189. import { getCache } from '@/utils/cache'
  190. import { IObject } from '@/types/interface'
  191. import { useDebounce } from '@/utils/utils'
  192. import { useRoute } from 'vue-router'
  193. import { IsPermission } from '@/router/routerUtil'
  194. import { getZxqdFindConfig } from "./data.js";
  195. const crudRef = ref()
  196. const agencyIdC = ref()
  197. const dataFormRef = ref()
  198. const url = ref()
  199. const serviceHallId = ref()
  200. const data = { bucket: '' }
  201. const parentSelectList = ref([] as IObject[])
  202. const upload = ref<UploadInstance>()
  203. //或取路由传入过来的对象数据
  204. const route = useRoute()
  205. const zxqdFind = ref(getZxqdFindConfig(route));;
  206. const vShowDoalog = ref(false);
  207. const crudRefTwo = ref();
  208. const tableItemData = ref([]);
  209. // 导入
  210. const uploadUrl = '/minIo/upload'
  211. let orderStep = ref('')
  212. const itemStartValue = ref("1")
  213. //查询参数
  214. const searchForm = ref({
  215. name: '', //网点名称
  216. serviceHallId: '', //网点编号
  217. agencyId: '', //渠道编号
  218. agencyName: '', //机构
  219. orderSource: 'WEB',
  220. })
  221. let tableData: any = ref([])
  222. const initItem = {
  223. name: '',
  224. superServiceHallId: '',
  225. serviceHallId: '',
  226. address: '',
  227. contact: '',
  228. mapChannelId: '',
  229. tel: '',
  230. orderSource: 'WEB',
  231. agencyId: '',
  232. locationModels: [
  233. ]
  234. }
  235. const addForm: any = ref(initItem)
  236. const formLoding = ref(false)
  237. const rules = reactive({
  238. // superServiceHallId: [{ required: true, message: '请输入', trigger: 'blur' }],
  239. serviceHallId: [{ required: true, message: '请输入', trigger: 'blur' }],
  240. name: [{ required: true, message: '请输入', trigger: 'blur' }],
  241. address: [{ required: true, message: '请输入', trigger: 'blur' }],
  242. tel: [{ required: true, message: '请输入', trigger: 'blur' }],
  243. contact: [{ required: true, message: '请输入', trigger: 'blur' }],
  244. longitude: [{ required: true, message: '请输入', trigger: 'blur' }],
  245. latitude: [{ required: true, message: '请输入', trigger: 'blur' }],
  246. radial: [{ required: true, message: '请输入', trigger: 'blur' }],
  247. agencyId: [{ required: true, message: '请选择', trigger: 'blur' }],
  248. mapChannelId: [{ required: true, message: '请输入', trigger: 'blur' }],
  249. })
  250. const typeOption = ref('')
  251. const agencyId = computed(() => {
  252. let cacheAccessToken = getCache(
  253. 'cacheAccessToken',
  254. { isSessionStorage: false },
  255. {}
  256. )
  257. return cacheAccessToken['agencyId']
  258. })
  259. onMounted(() => {
  260. getList()
  261. getAgencyList()
  262. })
  263. //新增
  264. const itemAdd = (data: any) => {
  265. request(data, itemStartValue.value)
  266. }
  267. const Adds = () => {
  268. console.log(zxqdFind.value.field[0].form);
  269. zxqdFind.value.field[0].form.hideEdit = false;
  270. itemStartValue.value = 1
  271. }
  272. //表单编辑按钮
  273. function itemEdit(idx: any, row: any) {
  274. console.log("我是编辑事件", idx, row);
  275. // request(row, 2)
  276. zxqdFind.value.field[0].form.hideEdit = true;
  277. itemStartValue.value = 2
  278. }
  279. //表单删除按钮
  280. function itemDelete(idx: any, row: any) {
  281. console.log("删除事件", idx, row);
  282. BaseService.postN('/userw/centerServiceHall/delete', row).then((res: any) => {
  283. if (res && res.code === 0) {
  284. getItmeLiet()
  285. crudRefTwo.value.reset();
  286. crudRefTwo.value.dialogFormVisible = false;
  287. } else {
  288. ElMessage.error(res.message)
  289. }
  290. })
  291. }
  292. const request = (data: any, type: any) => {
  293. data.optType = type //操作类型 1新增 2修改
  294. BaseService.postN('/userw/centerServiceHall/addOrUpDate', data).then((res: any) => {
  295. if (res && res.code === 0) {
  296. getItmeLiet()
  297. crudRefTwo.value.reset();
  298. crudRefTwo.value.dialogFormVisible = false;
  299. } else {
  300. ElMessage.error(res.message)
  301. }
  302. })
  303. }
  304. function handleCurrentChangeTwo(val: number) {
  305. console.log(val + '===');
  306. zxqdFind.value.paging.currentPage = val;
  307. getItmeLiet();
  308. }
  309. const getItmeLiet = () => {
  310. vShowDoalog.value = true
  311. if (crudRefTwo.value) {
  312. crudRefTwo.value.tableLoding = true;
  313. }
  314. let params: any = {
  315. methods: "page",
  316. pageNo: zxqdFind.value.paging.currentPage,
  317. pageSize: zxqdFind.value.paging.pageSize,
  318. }
  319. let searchFormList = { ...searchForm.value }
  320. for (let key in searchFormList) {
  321. if (searchFormList[key]) {
  322. params[key] = searchFormList[key]
  323. }
  324. }
  325. BaseService.postN('/userw/centerServiceHall/page', params).then((res: any) => {
  326. console.log(res, 'res')
  327. if (res && res.code === 0) {
  328. let bizContent = res.data
  329. let data = bizContent.result || [];
  330. data.forEach((item) => {
  331. if (item.models) item.models.forEach((i) => {
  332. if (i.agreementAnnex) i.fileList = [{ name: i.agreementAnnex }]
  333. })
  334. })
  335. console.log("bizContent12222", data)
  336. tableItemData.value = data;
  337. crudRefTwo.value.tableLoding = false;
  338. zxqdFind.value.paging.total = bizContent.totalCount;
  339. } else {
  340. crudRefTwo.value.tableLoding = false;
  341. ElMessage.error(res.message)
  342. }
  343. })
  344. }
  345. // 添加
  346. const addBtn = () => {
  347. addForm.value.locationModels.push({
  348. address: '',
  349. latitude: '',
  350. longitude: '',
  351. name: '',
  352. radial: '',
  353. })
  354. }
  355. // 删除
  356. const deleteHandle = (index) => {
  357. addForm.value.locationModels.splice(index, 1)
  358. }
  359. // 搜索按钮
  360. function btnSearch() {
  361. field.value.paging.currentPage = 1
  362. getList()
  363. }
  364. //标签分页
  365. function handleClick(tab, event) {
  366. orderStep.value = tab.props.name
  367. getList()
  368. }
  369. //分页
  370. function handleCurrentChange(val: number) {
  371. field.value.paging.currentPage = val
  372. getList()
  373. }
  374. function handleAvatarSuccess(response: any, row) {
  375. console.log(22222222222);
  376. console.log(response, row, 22222222222);
  377. const { ossFilePath, originalFileName } = response.data
  378. url.value = ossFilePath
  379. console.log(url.value, originalFileName)
  380. BaseService.postN('/userw/serviceHall/registerLocationBath', { excelFileUrl: url.value, serviceHallId: serviceHallId.value }).then((res: any) => {
  381. if (res && res.code === 0) {
  382. console.log(res)
  383. const errUrl = res.data?.path ?? ''
  384. if (errUrl) {
  385. ElMessage.error("导入失败,请查看下载到本地文件的具体错误信息");
  386. BaseService.getDownload(
  387. import.meta.env.VITE_APP_EXPORT_URL_NEW + errUrl,
  388. '错误信息文件'
  389. )
  390. } else {
  391. ElMessage.success("导入成功");
  392. url.value = ''
  393. }
  394. }
  395. })
  396. }
  397. const handleExceed: UploadProps['onExceed'] = (files) => {
  398. upload.value!.clearFiles()
  399. const file = files[0] as UploadRawFile
  400. file.uid = genFileId()
  401. upload.value!.handleStart(file)
  402. upload.value!.submit()
  403. }
  404. // 搜索重置
  405. function refreshLeft() {
  406. searchForm.value = {
  407. name: '', //网点名称
  408. serviceHallId: '', //网点编号
  409. agencyId: '', //渠道编号
  410. agencyName: '', //机构
  411. orderSource: 'WEB',
  412. }
  413. field.value.paging.currentPage = 1
  414. getList()
  415. }
  416. //获取列表
  417. function getList() {
  418. crudRef.value.tableLoding = true
  419. let params: any = {
  420. pageNo: field.value.paging.currentPage,
  421. pageSize: field.value.paging.pageSize,
  422. }
  423. //赋值查询参数
  424. let searchFormList = { ...searchForm.value }
  425. for (let key in searchFormList) {
  426. if (searchFormList[key]) {
  427. params[key] = searchFormList[key]
  428. }
  429. }
  430. BaseService.postN('/userw/serviceHall/serviceHallSelect', params).then((res: any) => {
  431. if (res && res.code === 0) {
  432. //数据转换
  433. let bizContent = res.data
  434. let data = bizContent.result || []
  435. //数据渲染
  436. tableData.value = data
  437. crudRef.value.tableLoding = false
  438. //分页总数
  439. field.value.paging.total = bizContent.totalCount
  440. } else {
  441. crudRef.value.tableLoding = false
  442. ElMessage.error(res.message)
  443. }
  444. })
  445. }
  446. let formLabelWidth = '130px'
  447. let contentWidth = '100%'
  448. //表单数据配置
  449. let field = ref({
  450. tabSize: 'small', //Table 的尺寸 large / default /small (默认default)
  451. searchShow: IsPermission(route, 'QUERY_BASE'), //是否显示搜索模块(默认false)
  452. border: true, //是否添加边框(默认false)
  453. dialogCustom: true, //自定义Dialog (默认false)
  454. dialogFooter: true, //隐藏弹窗页脚显示 (默认false)
  455. dialogWidth: '40%', //dialog宽度 (默认40%)
  456. crudShow: true, //是否显示CURD操作栏 (默认true)
  457. crudChildShow: true, //是否显示CURD子操作栏 (默认true)
  458. paginStart: true, //是否显示分页查询 (默认false)
  459. titleDialog: '', //table 标题
  460. dataListLoading: false,
  461. operateTitle: '操作', //操作栏标题(默认为"")
  462. operateWidth: "350px", //操作栏宽度
  463. crud: {
  464. add: IsPermission(route, 'ADD_BASE'),
  465. },
  466. operate: {
  467. edit: false, //是否编辑(默认true)
  468. delete: false, //是否删除(默认true)
  469. remark: false, // 详情
  470. announcement: false, // 公告
  471. forbidden: false, // 禁用
  472. enable: false, // 启用
  473. authorization: false, // 授权
  474. cancel: false, // 取消订单
  475. },
  476. searchOperation: {
  477. isDownload: false,
  478. isAdd: false,
  479. isTransferMachine: false,
  480. isToLead: true, // 导入
  481. isTemplate: true,
  482. templateUrl:
  483. import.meta.env.VITE_APP_EXPORT_URL_NEW +
  484. 'zhywpt-issuer/template/userw/网点信息导入模板.xlsx',
  485. templateFileName: '网点信息导入模板',
  486. },
  487. tableSize: -1,
  488. paging: {
  489. pageSize: 10,
  490. currentPage: 1,
  491. total: 0,
  492. },
  493. extend: [
  494. {
  495. label: '序号',
  496. type: 'index',
  497. width: '80px',
  498. },
  499. ],
  500. field: [
  501. {
  502. prop: 'agencyId',
  503. label: '渠道编号',
  504. },
  505. {
  506. prop: 'agencyName',
  507. label: '渠道名称',
  508. },
  509. {
  510. prop: 'superServiceHallId',
  511. label: '上级网点编号',
  512. },
  513. {
  514. prop: 'superServiceHallName',
  515. label: '上级网点名称',
  516. }, {
  517. prop: 'mapChannelId', //centerServiceHallId
  518. label: '中心网点编号',
  519. },
  520. {
  521. prop: 'serviceHallId',
  522. label: '网点编号',
  523. },
  524. {
  525. prop: 'name',
  526. label: '网点名称',
  527. },
  528. {
  529. prop: 'address',
  530. label: '网点地址',
  531. },
  532. {
  533. prop: 'tel',
  534. label: '联系人电话',
  535. },
  536. {
  537. prop: 'contact',
  538. label: '联系人',
  539. },
  540. ],
  541. })
  542. const isFirstDot = ref(false)
  543. function getServiceHallId(e) {
  544. //获取网点编号
  545. BaseService.postN('/userw/serviceHall/getServiceHallId', {
  546. agencyId: e,
  547. }).then((res: any) => {
  548. console.log(res, 'resresres');
  549. addForm.value.serviceHallId = res.data
  550. // load({isLeaf: false,key: res.data},()=>{})
  551. })
  552. }
  553. function getCenterServiceHall() {
  554. //获取中心网点编号信息 /userw/centerServiceHall/getCenterServiceHall
  555. BaseService.postN('/userw/centerServiceHall/getCenterServiceHall', {
  556. }).then((res: any) => {
  557. console.log(res, 'resresres');
  558. centerServiceHallIdList.value = res.data
  559. })
  560. }
  561. //添加中心网点编号
  562. const centerServiceHallIdChange = (value) => {
  563. console.log(value, 'eeee');
  564. addForm.value.mapChannelId = value
  565. // getServiceHallId(value)
  566. }
  567. function handleFirstDot() {
  568. //获取网点编号
  569. getCenterServiceHall()
  570. getServiceHallId(agencyId.value)
  571. isFirstDot.value = true
  572. crudRef.value.dialogFormVisible = true
  573. addForm.value.agencyId = agencyId.value
  574. }
  575. //添加一级网点切换所属渠道
  576. const agencyIdChange = (value) => {
  577. if(value===''||value===null||value===undefined){
  578. ElMessage.error("渠道不能为空!")
  579. return;
  580. }
  581. agencyIdC.value = value
  582. addForm.value.agencyId = value
  583. getServiceHallId(value)
  584. }
  585. const agencyList = ref<any>([])
  586. const centerServiceHallIdList = ref<any>([])
  587. // 获取所有渠道
  588. function getAgencyList() {
  589. BaseService.postN('/userw/agency/agencyqueryall').then((res: any) => {
  590. if (res && res.code === 0) {
  591. let bizContent = res.data
  592. console.log(bizContent, '------');
  593. let data = bizContent || []
  594. let list = [] as IObject[]
  595. data.map((item) => {
  596. list.push({
  597. label: item.name,
  598. value: item.agencyId,
  599. })
  600. })
  601. agencyList.value = list
  602. } else {
  603. ElMessage.error(res.message)
  604. }
  605. })
  606. }
  607. function importData(url) {
  608. // importFn('a8f9dac698cb4793bb15f26fd608d2b3', getList(), { excelFileUrl: url })
  609. BaseService.postN('/userw/serviceHall/registerFullBath', { excelFileUrl: url }).then((res: any) => {
  610. if (res && res.code === 0) {
  611. console.log(res)
  612. const errUrl = res.data?.path ?? ''
  613. if (errUrl) {
  614. ElMessage.error("导入失败,请查看下载到本地文件的具体错误信息");
  615. BaseService.getDownload(
  616. import.meta.env.VITE_APP_EXPORT_URL_NEW + errUrl,
  617. '错误信息文件'
  618. )
  619. } else {
  620. ElMessage.success("导入成功");
  621. }
  622. // //处理导入失败问题
  623. // if (res && res.code === 0) {
  624. // let bizContent = res.data
  625. // let url = bizContent.url || "";
  626. // let fileName = bizContent.fileName ? `${bizContent.fileName}` : ''
  627. // if (url) {
  628. // //window.open(url)
  629. // //处理下载有文件名
  630. // BaseService.getDownloadFileName(import.meta.env.VITE_APP_UPLOAD_URL + url, fileName)
  631. // // btnLoding.value = false;
  632. // // clearData();
  633. // // emit("refreshDataList");
  634. // // emit("closeHandle");
  635. // ElMessage.success("导入成功");
  636. // } else {
  637. // ElMessage.error("导入失败");
  638. // }
  639. // } else {
  640. // // btnLoding.value = false;
  641. // ElMessage.error(res.message);
  642. // }
  643. }
  644. });
  645. }
  646. function submitClick() {
  647. getCenterServiceHall()
  648. dataFormRef.value.validate((valid: boolean) => {
  649. if (!valid) {
  650. return false
  651. }
  652. let api = ''
  653. let params = {
  654. ...addForm.value,
  655. }
  656. if (typeOption.value === 'edit') {
  657. api = '/userw/serviceHall/serviceHallUpdate'
  658. } else {
  659. if (isFirstDot.value === false) {
  660. api = '/userw/serviceHall/serviceHallInsert'
  661. } else {
  662. delete params.superServiceHallId
  663. api = '/userw/serviceHall/serviceHallInsertnelevel'
  664. }
  665. }
  666. // if (!isFirstDot.value) {
  667. // params.agencyId = agencyId.value
  668. // }
  669. // agencyList.value.forEach(item => {
  670. // if (item.value === params.agencyId) {
  671. // params.agencyName = item.label
  672. // }
  673. // });
  674. if (!params.superServiceHallId) {
  675. params.superServiceHallId = null
  676. }
  677. BaseService.postN(api, params).then((res: any) => {
  678. if (res && res.code === 0) {
  679. ElMessage.success('操作成功')
  680. getList()
  681. cancel()
  682. } else {
  683. ElMessage.error(res.message)
  684. }
  685. })
  686. })
  687. }
  688. function removeNullValues(obj) {
  689. Object.keys(obj).forEach(key => {
  690. if (obj[key] === null) {
  691. delete obj[key];
  692. }
  693. });
  694. return obj;
  695. }
  696. const submitHandle = useDebounce(submitClick)
  697. function handleAdd() {
  698. console.log(1111);
  699. getServiceHallId(agencyId.value)
  700. getCenterServiceHall()
  701. isFirstDot.value = false
  702. addForm.value.agencyId = agencyId.value
  703. }
  704. const load = (node, resolve) => {
  705. // formLoding.value = true
  706. if (node.isLeaf) return resolve([])
  707. let serviceHallId = node.data.servicehallId
  708. console.log(node);
  709. if (!serviceHallId) { // 第一次获取数据
  710. let cacheAccessToken = getCache(
  711. 'cacheAccessToken',
  712. { isSessionStorage: false },
  713. {}
  714. )
  715. serviceHallId = cacheAccessToken['serviceHallId']
  716. BaseService.postN('/userw/serviceHall/serviceHallSonSelect', { serviceHallId })
  717. .then((res: any) => {
  718. if (res && res.code === 0) {
  719. let data = res.data || {}
  720. data.forEach(item => {
  721. if (item.childrens && item.childrens.length === 0) {
  722. item.isLeaf = true
  723. }
  724. })
  725. setTimeout(() => {
  726. resolve(data)
  727. }, 400)
  728. } else {
  729. ElMessage.error(res.message)
  730. }
  731. })
  732. .finally(() => {
  733. formLoding.value = false
  734. })
  735. } else {
  736. formLoding.value = false
  737. const children = node.data?.childrens ?? []
  738. children.forEach(item => {
  739. if (item.childrens && item.childrens.length === 0) {
  740. item.isLeaf = true
  741. }
  742. })
  743. setTimeout(() => {
  744. resolve(children)
  745. }, 400)
  746. }
  747. }
  748. // 树形数据处理
  749. function selectDataHandle(data: IObject[]): IObject[] {
  750. if (data === null || typeof data === 'undefined') return []
  751. let newData = [] as IObject[]
  752. data.map((item) => {
  753. let children = [] as IObject[]
  754. if (
  755. !(item.childrens === null || typeof item.childrens === 'undefined') &&
  756. item.childrens.length > 0
  757. ) {
  758. children = selectDataHandle(item.children)
  759. }
  760. newData.push({
  761. label: item.servicehallName,
  762. value: item.serviceHallId,
  763. children: children,
  764. })
  765. })
  766. return newData
  767. }
  768. //导入
  769. function handleImport(row) {
  770. serviceHallId.value = row.serviceHallId
  771. }
  772. //模板下载
  773. function handleFileName() {
  774. BaseService.getDownload(
  775. import.meta.env.VITE_APP_EXPORT_URL_NEW + 'zhywpt-issuer/template/userw/办理地址信息导入模板.xlsx',
  776. '办理地址信息导入模板'
  777. )
  778. }
  779. //编辑
  780. function handleEdit(row: IObject) {
  781. getCenterServiceHall()
  782. console.log('每项数据', row)
  783. let params = {
  784. orderSource: 'WEB',
  785. serviceHallId: row.serviceHallId
  786. }
  787. BaseService.postN('/userw/serviceHall/queryLocations', params).then((res: any) => {
  788. if (res && res.code === 0) {
  789. // ElMessage.success('操作成功')
  790. // getList()
  791. // cancel()
  792. addForm.value.locationModels = res.data
  793. } else {
  794. ElMessage.error(res.message)
  795. }
  796. })
  797. if (row.superServiceHallId) {
  798. isFirstDot.value = false
  799. } else {
  800. isFirstDot.value = true
  801. }
  802. const data = toRaw(row)
  803. typeOption.value = 'edit'
  804. addForm.value = {
  805. ...addForm.value,
  806. ...data,
  807. serviceHallId: row.serviceHallId,
  808. }
  809. crudRef.value.title = '编辑'
  810. crudRef.value.dialogFormVisible = true
  811. }
  812. // 删除
  813. function handleDetele(row: IObject) {
  814. if (row.superServiceHallId) {
  815. isFirstDot.value = false
  816. } else {
  817. isFirstDot.value = true
  818. }
  819. ElMessageBox.confirm('确定要操作么?', '', {
  820. confirmButtonText: '确定',
  821. cancelButtonText: '取消',
  822. type: 'error',
  823. })
  824. .then(() => {
  825. BaseService.postN('/userw/serviceHall/serviceHallDelete', {
  826. status: row.state==='ENABLE'?'DISABLE':'ENABLE',
  827. serviceHallId: row.serviceHallId,
  828. orderSource: 'WEB',
  829. id: row.id,
  830. }).then((res: any) => {
  831. if (res && res.code === 0) {
  832. getList()
  833. ElMessage.success(row.state==='ENABLE'?'禁用成功':'启用成功')
  834. } else {
  835. ElMessage.error(res.message)
  836. }
  837. })
  838. })
  839. .catch(() => {
  840. console.log('====取消')
  841. })
  842. }
  843. // 取消
  844. function cancel() {
  845. addForm.value = JSON.parse(JSON.stringify(initItem)) //清空数据
  846. dataFormRef.value.resetFields()
  847. crudRef.value.reset()
  848. crudRef.value.dialogFormVisible = false
  849. typeOption.value = ''
  850. crudRef.value.title = ''
  851. parentSelectList.value = []
  852. }
  853. </script>
  854. <style lang="scss" scoped></style>