index.vue 15 KB

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