index.vue 13 KB

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