index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <template>
  2. <div class="my-container">
  3. <!-- <transition-group name="fade" style="position: relative;width: 100%;display: flex;"> -->
  4. <div class="bill-left" v-show="isShow==='home'" key="item">
  5. <div class="bill-tab">
  6. <div class="bill-title">导航</div>
  7. <side-tree :propConfig="treeConfig" @onChange="onChangeTree" ref="sideTree" />
  8. </div>
  9. </div>
  10. <div class="bill-main" v-show="isShow==='home'" key="item2">
  11. <module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="getDataList"
  12. @resert="onRefresh" @clickHandle="clickHandle" @detail="openEdit" @onRefresh="onRefresh">
  13. </module-view>
  14. </div>
  15. <!-- 新增/编辑弹窗 -->
  16. <div class="detil" v-show="isShow==='add'" key="item3">
  17. <by-tool :propConfig="toolConfig" @clickHandle="insideTools" ref="byTool" />
  18. <div class="box-shadow">
  19. <by-form :propConfig="addConfig" ref="addFormId">
  20. <template v-slot:k3ServerUrl="{value}" class="clearfix">
  21. <!-- <i class="el-icon-question" title="私有云必须配置金蝶云星空产品地址,K3Cloud/结尾,若为公有云则必须置空"></i> -->
  22. <!-- <vxe-input v-model="value.k3ServerUrl" style="width:calc(100% - 25px);margin-left: 10px;"></vxe-input> -->
  23. <vxe-input v-model="value.k3ServerUrl" style="width: 27.2%;"></vxe-input>
  24. <div style="display: inline-block;margin-left: 17px;color: #ababab;">
  25. <span style="color: red;margin-right: 5px;">*</span>私有云必须配置金蝶云星空产品地址,K3Cloud/结尾,若为公有云则必须置空
  26. </div>
  27. </template>
  28. <template v-slot:status class="clearfix">
  29. <el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="0">正常</el-radio>
  30. <el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="1">禁用</el-radio>
  31. </template>
  32. </by-form>
  33. </div>
  34. </div>
  35. <!-- </transition-group> -->
  36. </div>
  37. </template>
  38. <script lang="ts">
  39. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  40. import api from "@/api/currency";
  41. import Assembly from "@/components/Assembly/material.vue";
  42. @Component
  43. export default class Supplier extends Vue {
  44. isShow = 'home'
  45. timeNum = 0;
  46. timer : any = null
  47. popTitle : any = ''
  48. radio : any = 0
  49. dialogFormVisible : boolean = false
  50. categoryIds : any = '';
  51. toolConfig = {
  52. tools: {
  53. return: true,
  54. save: true,
  55. }
  56. }
  57. treeConfig = {
  58. attr: {
  59. retConfig: {
  60. id: 'id',
  61. },
  62. defaultExpandAll: true,
  63. label: 'name',
  64. // resType: 'data'
  65. },
  66. // request: {
  67. // url: '/maindata/maindataOrganizationCategory/treeUseList',
  68. // method: 'GET'
  69. // }
  70. }
  71. config : any = {
  72. attr: {
  73. calculateH: true
  74. },
  75. search: {
  76. attr: {
  77. size: 'mini'
  78. },
  79. columns: [
  80. [{
  81. span: 6,
  82. label: '名称',
  83. prop: 'name',
  84. component: 'by-input',
  85. labelWidth: '70px',
  86. compConfig: {
  87. attr: {
  88. placeholder: '请输入名称',
  89. clearable: true
  90. },
  91. },
  92. }, {
  93. span: 6,
  94. label: '负责人',
  95. prop: 'contacts',
  96. component: 'by-input',
  97. labelWidth: '70px',
  98. compConfig: {
  99. attr: {
  100. placeholder: '请输入负责人',
  101. clearable: true
  102. }
  103. }
  104. },
  105. {
  106. span: 6,
  107. label: '状态',
  108. prop: 'status',
  109. labelWidth: '70px',
  110. component: 'by-select',
  111. compConfig: {
  112. attr: {
  113. placeholder: '请选择状态',
  114. clearable: true,
  115. size: 'small',
  116. data: [{
  117. value: 0,
  118. label: '正常'
  119. }, {
  120. value: 1,
  121. label: '禁用'
  122. }]
  123. }
  124. }
  125. },
  126. ]
  127. ]
  128. },
  129. tool: {
  130. tools: {
  131. add: true,
  132. search: true,
  133. refresh: true
  134. }
  135. },
  136. table: {
  137. attr: {
  138. size: 'mini',
  139. align: 'left',
  140. },
  141. columns: [{
  142. title: '名称',
  143. field: 'name',
  144. isDetail: true,
  145. width: 150,
  146. },
  147. {
  148. title: '负责人',
  149. field: 'contacts',
  150. width: 120,
  151. },
  152. {
  153. title: '联系电话',
  154. field: 'phonenum',
  155. width: 150,
  156. },
  157. {
  158. title: '手机号码',
  159. field: 'telephone',
  160. width: 150,
  161. },
  162. {
  163. width: 300,
  164. title: '财务系统类型',
  165. field: 'financeType2',
  166. },
  167. {
  168. width: 80,
  169. title: '状态',
  170. field: 'status',
  171. component: Assembly,
  172. }, {
  173. width: 120,
  174. title: '操作',
  175. action: true,
  176. plugins: [{
  177. icon: 'el-icon-edit',
  178. name: '编辑',
  179. audit: '',
  180. event: {
  181. click: (item : any) => {
  182. (this as any).openEdit(item)
  183. }
  184. }
  185. }, {
  186. name: '删除',
  187. event: {
  188. click: (item : any) => (this as any).doDelete(item)
  189. }
  190. }]
  191. }]
  192. },
  193. }
  194. addConfig = {
  195. attr: {
  196. size: 'medium',
  197. rules: {
  198. categoryName: [{
  199. required: true, message: '请选择机构分类', trigger: 'change'
  200. }],
  201. name: [{
  202. required: true, message: '请输入名称', trigger: 'blur'
  203. }],
  204. contacts: [{
  205. required: true, message: '请输入负责人', trigger: 'blur'
  206. }],
  207. telephone: [{
  208. required: true, message: '请输入手机号码', trigger: 'blur'
  209. }],
  210. // phonenum: [{
  211. // required: true, message: '请输入联系电话', trigger: 'blur'
  212. // }],
  213. financeType: [{
  214. required: true, message: '请输入财务系统类型', trigger: 'change'
  215. }],
  216. province: [{
  217. required: true, message: '请选择地址', trigger: 'change'
  218. }],
  219. address: [{
  220. required: true, message: '请输入详细地址', trigger: 'blur'
  221. }],
  222. }
  223. },
  224. columns: [
  225. [
  226. {
  227. span: 6,
  228. label: '机构分类',
  229. prop: 'categoryName',
  230. component: 'select-tree',
  231. compConfig: {
  232. attr: {
  233. label: 'name',
  234. clearable: true,
  235. retConfig: {
  236. categoryId: 'id',
  237. categoryName: 'name',
  238. },
  239. defaultExpandAll: true
  240. },
  241. request: {
  242. url: '/maindata/maindataOrganizationCategory/treeUseList'
  243. }
  244. }
  245. },
  246. {
  247. span: 6,
  248. label: '名称',
  249. prop: 'name',
  250. component: 'by-input',
  251. },
  252. {
  253. span: 6,
  254. label: '负责人',
  255. prop: 'contacts',
  256. component: 'by-input',
  257. },
  258. {
  259. span: 6,
  260. label: '手机号码',
  261. prop: 'telephone',
  262. component: 'by-input',
  263. },
  264. ],
  265. [{
  266. span: 6,
  267. label: '联系电话',
  268. prop: 'phonenum',
  269. component: 'by-input',
  270. },
  271. ],
  272. [
  273. {
  274. span: 6,
  275. labelWidth: '110px',
  276. label: '财务系统类型',
  277. prop: 'financeType',
  278. component: 'by-select',
  279. compConfig: {
  280. attr: {
  281. placeholder: '请选择财务系统类型',
  282. clearable: true,
  283. size: 'small',
  284. data: [
  285. {
  286. value: 'kingdee',
  287. label: '金蝶K3'
  288. },
  289. // {
  290. // value: 'yonbip',
  291. // label: '用友U8'
  292. // },
  293. ]
  294. }
  295. }
  296. },
  297. ],
  298. [
  299. {
  300. span: 18,
  301. label: 'URL地址',
  302. slot: true,
  303. prop: 'k3ServerUrl',
  304. },
  305. ],
  306. [
  307. {
  308. span: 6,
  309. label: '登录授权ID',
  310. slot: true,
  311. prop: 'k3AppId',
  312. component: 'by-input',
  313. },
  314. {
  315. span: 6,
  316. label: '用户名称',
  317. slot: true,
  318. prop: 'k3UserName',
  319. component: 'by-input',
  320. },
  321. {
  322. span: 6,
  323. label: '数据中心ID',
  324. slot: true,
  325. prop: 'k3AcctId',
  326. component: 'by-input',
  327. },
  328. {
  329. span: 6,
  330. label: '应用秘钥',
  331. slot: true,
  332. prop: 'k3AppSec',
  333. component: 'by-input',
  334. },
  335. ],
  336. [{
  337. span: 18,
  338. label: '地址',
  339. prop: 'province',
  340. component: 'by-area',
  341. labelWidth: '100px',
  342. compConfig: {
  343. attr: {
  344. province: 'province', //省
  345. provinceCode: 'provinceCode', //省编码
  346. city: 'city', //市
  347. cityCode: 'cityCode', //市编码
  348. county: 'region', //县/区
  349. countyCode: 'regionCode', //县/区编码
  350. town: 'street', //街道
  351. townCode: 'streetCode', //街道编码
  352. }
  353. }
  354. }],
  355. [
  356. {
  357. span: 18,
  358. label: '详细地址',
  359. slot: true,
  360. prop: 'address',
  361. component: 'by-input',
  362. },
  363. ],
  364. [
  365. {
  366. span: 6,
  367. label: '状态',
  368. slot: true,
  369. prop: 'status',
  370. },
  371. ]
  372. ]
  373. }
  374. mounted() {
  375. this.timer = setInterval(() => {
  376. this.getDataList()
  377. }, 300)
  378. this.getTreeList();
  379. }
  380. getTreeList(){
  381. api.treeList('maindataOrganizationCategory').then((res : any) => {
  382. console.log(res);
  383. var data:any = [{
  384. id: 0,
  385. name: '机构分类',
  386. children: res.data
  387. }];
  388. (this as any).$refs.sideTree.setData(data);
  389. })
  390. }
  391. //点击树获取数据
  392. onChangeTree(e : any) {
  393. this.categoryIds = e.id;
  394. var ids:any = e.id;
  395. if(e.id[0]==0) ids = 0;
  396. let loading = this.$loading({ target: '.main-container' });
  397. api.byCategoryPage({ categoryId: ids, type: 3 }, 'maindataOrganizationCategory').then((res : any) => {
  398. if (res.code === 200) {
  399. (this.$refs.moduleView as any).setTableValue(res.data.records);
  400. let page = {
  401. pageNo: res.data.current, //当前页
  402. pageSize: res.data.size, //每页条数
  403. total: res.data.total //总条数
  404. };
  405. (this.$refs.moduleView as any).setPage(page);
  406. loading.close();
  407. } else loading.close();
  408. }).catch(() => loading.close());
  409. }
  410. // 内页工具栏方法
  411. insideTools(e : any) {
  412. console.log(e);
  413. if (e === 'onReturn') this.isShow = 'home';
  414. if (e === 'onSave') this.confirm();
  415. }
  416. // 保存新增/编辑
  417. confirm() {
  418. (this as any).$refs.addFormId.validate().then(() => {
  419. let query = (this as any).$refs.addFormId.getValue();
  420. query.status = this.radio;
  421. query.accountId = this.$store.getters.userInfo.userId;
  422. // 手机验证
  423. let reg = /^1[3456789]\d{9}$/;
  424. // let reg2 = /^0\d{2,3}-\d{7,8}$/;
  425. if (query.telephone && !reg.test(query.telephone)) return this.$message.warning('请输入正确手机号码');
  426. // if (query.phonenum && !reg2.test(query.phonenum)) return this.$message.warning('请输入正确联系电话');
  427. if(query.phonenum){
  428. if (query.phonenum.length>20 || query.phonenum[0]==' ') {
  429. return this.$message.warning('请输入正确联系电话');
  430. }
  431. }
  432. if (!query.telephone) query.telephone = null;
  433. if (!query.phonenum) query.phonenum = null;
  434. this.dialogFormVisible = false;
  435. console.log(query);
  436. let loading = this.$loading({ target: '.main-container' });
  437. if (this.popTitle === '新增') {
  438. api.saveList(query, 'maindataMaterialManufacturer').then((res : any) => {
  439. loading.close();
  440. if (res.code === 200) {
  441. this.$message.success('保存成功');
  442. // (this as any).$refs.sideTree.request();
  443. this.getTreeList();
  444. this.isShow = 'home'; // 展示类型
  445. this.getDataList();
  446. } else this.$message.error(res.msg);
  447. }).catch(() => loading.close());
  448. } else if (this.popTitle === '编辑') {
  449. api.updateList(query, 'maindataMaterialManufacturer').then((res : any) => {
  450. loading.close();
  451. if (res.code === 200) {
  452. this.$message.success('编辑成功');
  453. // (this as any).$refs.sideTree.request();
  454. this.getTreeList();
  455. this.isShow = 'home'; // 展示类型
  456. this.getDataList();
  457. } else this.$message.error(res.msg);
  458. }).catch(() => loading.close());
  459. }
  460. }).catch(() => {});
  461. }
  462. // 获取列表数据
  463. getDataList() {
  464. if (!this.$refs.moduleView) {
  465. if (this.timeNum > 5) {
  466. clearInterval(this.timer)
  467. }
  468. this.timeNum++;
  469. return
  470. }
  471. clearInterval(this.timer)
  472. let query = (this.$refs.moduleView as any).getQuery();
  473. if (this.categoryIds) query.categoryIds = this.categoryIds;
  474. console.log('表单字段 ==> ', query);
  475. this.getPageList(query)
  476. }
  477. getPageList(query : any) {
  478. let loading = this.$loading({ target: '.main-container' });
  479. api.pageList(query, 'maindataMaterialManufacturer').then((res : any) => {
  480. loading.close();
  481. if (res.code === 200) {
  482. res.data.records.map((v : any) => {
  483. if (v.financeType === 'kingdee') v.financeType2 = '金蝶K3';
  484. if (v.financeType === 'yonbip') v.financeType2 = '用友U8';
  485. });
  486. (this.$refs.moduleView as any).setTableValue(res.data.records);
  487. let page = {
  488. pageNo: res.data.current, //当前页
  489. pageSize: res.data.size, //每页条数
  490. total: res.data.total //总条数
  491. };
  492. (this.$refs.moduleView as any).setPage(page);
  493. } else this.$message.error(res.msg);
  494. }).catch(() => loading.close());
  495. }
  496. // 工具栏方法
  497. clickHandle(e : any) {
  498. if (e === 'onAdd') this.onAdd();
  499. }
  500. // 打开新增
  501. onAdd() {
  502. this.isShow = 'add'; // 展示类型
  503. this.popTitle = '新增'
  504. this.dialogFormVisible = true;
  505. this.radio = 0
  506. this.$nextTick(() => (this as any).$refs.addFormId.setValue());
  507. }
  508. // 打开编辑
  509. openEdit(e : any) {
  510. console.log('打开编辑 ==> ', e);
  511. this.isShow = 'add'; // 展示类型
  512. this.popTitle = '编辑'
  513. let loading = this.$loading({ target: '.main-container' });
  514. api.single({ id: e.id }, 'maindataMaterialManufacturer').then((res : any) => {
  515. if (res.code === 200) {
  516. let data = res.data;
  517. this.radio = data.status;
  518. this.dialogFormVisible = true;
  519. this.$nextTick(() => (this as any).$refs.addFormId.setValue(data));
  520. loading.close();
  521. } else loading.close();
  522. }).catch(() => loading.close());
  523. }
  524. // 操作删除
  525. doDelete(item : any) {
  526. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  527. confirmButtonText: '确定',
  528. cancelButtonText: '取消',
  529. type: 'warning',
  530. center: true
  531. }).then(() => {
  532. let loading = this.$loading({ target: '.main-container' });
  533. api.deleteList({ ids: item.id }, 'maindataMaterialManufacturer').then((res : any) => {
  534. loading.close();
  535. if (res.code === 200) {
  536. // (this as any).$refs.sideTree.request();
  537. this.getTreeList();
  538. this.getDataList();
  539. this.$message.success('删除成功');
  540. } else this.$message.error(res.msg);
  541. }).catch(() => loading.close());
  542. }).catch(() => this.$message.info('已取消删除'));
  543. }
  544. // 刷新/重置
  545. onRefresh() {
  546. (this as any).$refs.moduleView.clearSearch();
  547. // (this as any).$refs.sideTree.request();
  548. this.getTreeList();
  549. this.categoryIds = '';
  550. this.getDataList();
  551. }
  552. }
  553. </script>
  554. <style lang="scss" scoped>
  555. .my-container {
  556. width: 100%;
  557. box-sizing: border-box;
  558. display: flex;
  559. padding: 16px;
  560. height: 100%;
  561. .bill-left {
  562. position: relative;
  563. border-right: solid #EEE 1px;
  564. padding-right: 16px;
  565. flex-shrink: 0;
  566. .bill-tab {
  567. width: 210px;
  568. height: 100%;
  569. transition: all .5s;
  570. overflow: auto;
  571. }
  572. .tab-title {
  573. font-size: 16px;
  574. padding-bottom: 16px;
  575. width: 200px;
  576. }
  577. }
  578. .bill-main {
  579. width: calc(100% - 16px);
  580. box-sizing: border-box;
  581. margin-left: 16px;
  582. position: relative;
  583. height: 100%;
  584. overflow-y: hidden;
  585. }
  586. .detil {
  587. width: 100%;
  588. .box-shadow {
  589. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  590. padding: 20px;
  591. border-radius: 4px;
  592. border: 1px solid #e6ebf5;
  593. background-color: #fff;
  594. overflow: hidden;
  595. color: #303133;
  596. -webkit-transition: .3s;
  597. transition: .3s;
  598. margin-top: 20px;
  599. }
  600. }
  601. }
  602. </style>