index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  1. <template>
  2. <div class="app-container">
  3. <el-row type="flex" justify="space-around" style="margin-bottom: 20px">
  4. <div class="grid-content bg-purple">
  5. <el-input
  6. placeholder="请输入供应商名称"
  7. v-model="formData.name"
  8. @change="Search"
  9. clearable
  10. style="width: 100%"
  11. >
  12. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  13. </el-input>
  14. </div>
  15. <!-- 审核状态 -->
  16. <div class="grid-content bg-purple">
  17. <el-dropdown @command="AhandleCommand">
  18. <div class="pulldown">
  19. <span v-if="!Auditstatus" class="el-dropdown-link"> 审核状态 </span>
  20. <span v-if="Auditstatus" class="el-dropdown-link">
  21. {{ Auditstatus }}
  22. </span>
  23. <i class="el-icon-arrow-down el-icon--right" />
  24. </div>
  25. <el-dropdown-menu slot="dropdown">
  26. <el-dropdown-item command="全部">全部</el-dropdown-item>
  27. <el-dropdown-item command="已认证">已认证</el-dropdown-item>
  28. <el-dropdown-item command="未认证">未认证</el-dropdown-item>
  29. </el-dropdown-menu>
  30. </el-dropdown>
  31. </div>
  32. <!-- 供应商状态 -->
  33. <div class="grid-content bg-purple">
  34. <el-dropdown @command="handleCommand">
  35. <div class="pulldown">
  36. <span v-if="!providerStatus" class="el-dropdown-link">
  37. 供应商状态
  38. </span>
  39. <span v-if="providerStatus" class="el-dropdown-link">
  40. {{ providerStatus }}
  41. </span>
  42. <i class="el-icon-arrow-down el-icon--right" />
  43. </div>
  44. <el-dropdown-menu slot="dropdown">
  45. <el-dropdown-item command="全部">全部</el-dropdown-item>
  46. <el-dropdown-item command="正常">正常</el-dropdown-item>
  47. <el-dropdown-item command="删除">删除</el-dropdown-item>
  48. </el-dropdown-menu>
  49. </el-dropdown>
  50. </div>
  51. <!-- 日期查询 -->
  52. <div class="grid-content bg-purple">
  53. <div class="block">
  54. <el-date-picker
  55. v-model="value2"
  56. type="daterange"
  57. align="right"
  58. unlink-panels
  59. range-separator="至"
  60. start-placeholder="开始日期"
  61. end-placeholder="结束日期"
  62. :picker-options="pickerOptions"
  63. value-format="yyyy-MM-dd"
  64. @change="startEndTime"
  65. />
  66. </div>
  67. </div>
  68. </el-row>
  69. <el-table
  70. :row-key="getRowKey"
  71. v-loading="listLoading"
  72. :data="temporaryList"
  73. element-loading-text="Loading"
  74. border
  75. fit
  76. highlight-current-row
  77. @selection-change="handleSelectionChange"
  78. @select-all="handleAll"
  79. >
  80. <el-table-column type="selection" :reserve-selection="true"> </el-table-column>
  81. <el-table-column
  82. label="供应商名称"
  83. align="center"
  84. prop="name"
  85. width="200"
  86. >
  87. </el-table-column>
  88. <el-table-column
  89. label="统一社会信用代码"
  90. width="200"
  91. align="center"
  92. prop="socialCode"
  93. >
  94. </el-table-column>
  95. <el-table-column label="账号" width="150" align="center" prop="account">
  96. </el-table-column>
  97. <el-table-column
  98. label="法人姓名"
  99. width="180"
  100. align="center"
  101. prop="legalPerson"
  102. >
  103. </el-table-column>
  104. <el-table-column
  105. label="联系人"
  106. width="180"
  107. align="center"
  108. prop="contacts"
  109. >
  110. </el-table-column>
  111. <el-table-column label="联系电话" width="180" align="center" prop="contactsMobile">
  112. </el-table-column>
  113. <el-table-column label="审核状态" align="center" prop="statusText">
  114. </el-table-column>
  115. <el-table-column label="供应商状态" align="center" prop="isDeletedText" width="120">
  116. </el-table-column>
  117. <el-table-column align="center" prop="createdAt" label="时间" width="180">
  118. </el-table-column>
  119. <el-table-column align="center" prop="created_at" label="操作" width="250">
  120. <template slot-scope="scope">
  121. <el-tag type="primary" style="cursor: pointer; margin-right: 15px" @click="toedit(scope.row.id)">详情
  122. </el-tag>
  123. <el-tag type="success" style="margin-right: 15px; cursor: pointer" @click="Srecover(scope.row.id)"
  124. v-if="scope.row.isDeleted == 1">恢复</el-tag>
  125. <el-tag type="danger" style="margin-right: 15px; cursor: pointer" @click="Sdeleted(scope.row.id)"
  126. v-if="scope.row.isDeleted == 0">删除</el-tag>
  127. <el-tag type="primary" style="margin-right: 15px; cursor: pointer" @click="reset(scope.row.id)"
  128. v-permission="['admin']">重置密码</el-tag>
  129. </template>
  130. </el-table-column>
  131. </el-table>
  132. <!-- 重置密码弹窗 -->
  133. <el-dialog title="重置密码" :visible.sync="dialogVisible" width="30%">
  134. <el-form ref="form" :model="password" label-width="80px">
  135. <el-form-item label="登录密码" prop="password.newpassword">
  136. <el-input v-model="password.newpassword" style="width: 300px" show-password></el-input>
  137. </el-form-item>
  138. <el-form-item label="确认密码" prop="password.ConfirmnewPassword">
  139. <el-input v-model="password.ConfirmnewPassword" style="width: 300px" show-password></el-input>
  140. </el-form-item>
  141. <el-form-item>
  142. <el-button @click="dialogVisible = false">取 消</el-button>
  143. <el-button type="primary" @click="onSubmit">提交修改</el-button>
  144. </el-form-item>
  145. </el-form>
  146. </el-dialog>
  147. <div style="display: flex; justify-content: space-between">
  148. <el-row type="flex" justify="end">
  149. <div class="btn" style="display: flex; justify-content: flex-end">
  150. <el-button type="primary" @click="failed">认证失败</el-button>
  151. <el-button type="primary" @click="success">认证成功</el-button>
  152. <el-button type="primary" @click="batchExports">导出</el-button>
  153. <el-button type="success" @click="recover">恢复</el-button>
  154. <el-button type="danger" @click="deleted">删除</el-button>
  155. </div>
  156. </el-row>
  157. <div class="pagesip">
  158. <el-button type="primary" size="small" style="
  159. background-color: #d8ab5a;
  160. border-color: #d8ab5a;
  161. margin: 0 20px;
  162. " @click="jumpFirstPage">首页
  163. </el-button>
  164. <el-pagination background @current-change="handleCurrentChange" layout="total,prev, pager, next"
  165. :total="total" :page-size="pagesize" :current-page="currentPage" prev-text="上一页" next-text="下一页"
  166. :hide-on-single-page="false" ref="pagination">
  167. </el-pagination>
  168. <el-button type="primary" size="small" style="
  169. background-color: #d8ab5a;
  170. border-color: #d8ab5a;
  171. margin: 0 20px;
  172. " @click="jumpLastPage">尾页
  173. </el-button>
  174. </div>
  175. </div>
  176. </div>
  177. </template>
  178. <script>
  179. import {
  180. dataConversionUtil
  181. } from "../../utils/Excel.js";
  182. import {
  183. getSupplierSearch
  184. } from "@/api/supplier";
  185. export default {
  186. filters: {
  187. statusFilter(status) {
  188. const statusMap = {
  189. published: "success",
  190. draft: "gray",
  191. deleted: "danger",
  192. };
  193. return statusMap[status];
  194. },
  195. },
  196. data() {
  197. return {
  198. //重置密码
  199. password: {
  200. newpassword: "",
  201. ConfirmnewPassword: "",
  202. supplierId: "",
  203. },
  204. // 控制弹窗
  205. dialogVisible: false,
  206. // 表单数据
  207. formData: {
  208. startTime: "",
  209. endTime: "",
  210. name: "",
  211. status: "",
  212. socialCode: "",
  213. legalPerson: "",
  214. isDeleted: "",
  215. },
  216. /* 当前页数 */
  217. currentPage: 1,
  218. /* 每页显示个数 */
  219. pagesize: 10,
  220. /* 总条数 */
  221. total: 20,
  222. srcList: [],
  223. list: [],
  224. temporaryList: [],
  225. listLoading: false,
  226. providerStatus: "",
  227. search: "",
  228. Auditstatus: "",
  229. multipleSelection: [],
  230. checked: false,
  231. pickerOptions: {
  232. shortcuts: [{
  233. text: "最近一周",
  234. onClick(picker) {
  235. const end = new Date();
  236. const start = new Date();
  237. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  238. picker.$emit("pick", [start, end]);
  239. },
  240. },
  241. {
  242. text: "最近一个月",
  243. onClick(picker) {
  244. const end = new Date();
  245. const start = new Date();
  246. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  247. picker.$emit("pick", [start, end]);
  248. },
  249. },
  250. {
  251. text: "最近三个月",
  252. onClick(picker) {
  253. const end = new Date();
  254. const start = new Date();
  255. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  256. picker.$emit("pick", [start, end]);
  257. },
  258. },
  259. ],
  260. },
  261. value1: "",
  262. value2: "",
  263. exportExcelData1: [], //列表缓存数据
  264. exportExcelData2: [],
  265. };
  266. },
  267. mounted() {
  268. this.checked = this.$store.state.user.checked;
  269. this.getAllList();
  270. },
  271. methods: {
  272. /* 获取列表数据 */
  273. getAllList(searchForm = {}) {
  274. const params = {
  275. pageIndex: this.currentPage,
  276. pageSize: this.pagesize,
  277. };
  278. getSupplierSearch({
  279. ...params,
  280. ...searchForm
  281. }).then((res) => {
  282. const {
  283. data
  284. } = res;
  285. this.temporaryList = data.result;
  286. this.srcList = data.result;
  287. this.total = res.data.total;
  288. });
  289. },
  290. toedit(id) {
  291. this.$router.push({
  292. path: "/edit",
  293. query: {
  294. id: id,
  295. },
  296. });
  297. },
  298. // 日期审核状态查询
  299. startEndTime(item) {
  300. if (item == null) {
  301. item = [];
  302. this.formData.startTime = "";
  303. this.formData.endTime = "";
  304. this.currentPage = 1;
  305. this.searchForm = {
  306. ...this.formData
  307. };
  308. this.getAllList(this.searchForm);
  309. } else {
  310. this.formData.startTime = this.value2[0];
  311. this.formData.endTime = this.value2[1];
  312. this.currentPage = 1;
  313. this.searchForm = {
  314. ...this.formData
  315. };
  316. this.getAllList(this.searchForm);
  317. }
  318. },
  319. /* 审核状态查询 */
  320. handleCommand(command) {
  321. this.providerStatus = command;
  322. if (command === "全部") {
  323. this.formData.isDeleted = "";
  324. }
  325. if (command === "正常") {
  326. this.formData.isDeleted = 0;
  327. }
  328. if (command === "删除") {
  329. this.formData.isDeleted = 1;
  330. }
  331. this.currentPage = 1;
  332. this.searchForm = {
  333. ...this.formData
  334. };
  335. this.getAllList(this.searchForm);
  336. },
  337. // 输入供应商状态查询
  338. AhandleCommand(command) {
  339. this.Auditstatus = command;
  340. if (command === "全部") {
  341. this.formData.status = "";
  342. }
  343. if (command === "已认证") {
  344. this.formData.status = 2;
  345. }
  346. if (command === "未认证") {
  347. this.formData.status = 1;
  348. }
  349. this.currentPage = 1;
  350. this.searchForm = {
  351. ...this.formData
  352. };
  353. this.getAllList(this.searchForm);
  354. },
  355. /* 输入出票人名称查询 */
  356. Search() {
  357. this.currentPage = 1;
  358. this.searchForm = {
  359. ...this.formData,
  360. };
  361. this.getAllList(this.searchForm);
  362. },
  363. /* 分页功能,改变当前页 */
  364. handleCurrentChange(val) {
  365. this.currentPage = val;
  366. this.getAllList(this.searchForm);
  367. },
  368. /* 分页功能去首页 */
  369. jumpFirstPage() {
  370. this.$refs.pagination.handleCurrentChange(1);
  371. this.$emit("handleCurrentChange", 1);
  372. },
  373. /* 分页功能:去尾页 */
  374. jumpLastPage() {
  375. let font = this.$refs.pagination;
  376. let cpage = Math.ceil(font.total / font.pageSize);
  377. font.handleCurrentChange(cpage);
  378. },
  379. getRowKey(row) {
  380. return row.id;
  381. },
  382. /* 批量导出数据 */
  383. handleSelectionChange(data) {
  384. this.multipleSelection = data
  385. console.log(this.multipleSelection)
  386. },
  387. handleAll(data) {
  388. this.multipleSelection = data
  389. },
  390. /* 批量导出数据 */
  391. batchExports() {
  392. if (this.multipleSelection == "") {
  393. this.Exports()
  394. } else {
  395. var tableHeader = [
  396. [
  397. "序号",
  398. "供应商名称",
  399. "社会统一信用码",
  400. "账号",
  401. "法人名称",
  402. "联系人",
  403. "电话",
  404. "审核状态",
  405. "时间",
  406. ],
  407. ];
  408. var dataList = [];
  409. this.multipleSelection.forEach((item, index) => {
  410. dataList.push([
  411. index + 1,
  412. item.name,
  413. item.socialCode,
  414. item.account,
  415. item.legalPerson,
  416. item.contacts,
  417. item.contactsMobile,
  418. item.statusText,
  419. item.createdAt,
  420. ]);
  421. });
  422. dataConversionUtil.dataToExcel("供应商列表", tableHeader, dataList);
  423. this.$message.success("导出成功!");
  424. }
  425. },
  426. /* 全部导出承兑人列表数据 */
  427. getContacts() {
  428. const data = {
  429. pageIndex: "",
  430. pageSize: -1,
  431. startTime: "",
  432. endTime: "",
  433. name: "",
  434. status: "",
  435. socialCode: "",
  436. legalPerson: "",
  437. isDeleted: "",
  438. };
  439. getSupplierSearch({
  440. ...data
  441. }).then((res) => {
  442. const {
  443. result
  444. } = res.data;
  445. this.multipleSelection = result;
  446. });
  447. },
  448. /* 全部导出 */
  449. Exports() {
  450. this.getContacts();
  451. setTimeout(() => {
  452. var tableHeader = [
  453. [
  454. "序号",
  455. "供应商名称",
  456. "社会统一信用码",
  457. "账号",
  458. "法人名称",
  459. "联系人",
  460. "电话",
  461. "审核状态",
  462. "时间",
  463. ],
  464. ];
  465. var dataList = [];
  466. this.multipleSelection.forEach((item, index) => {
  467. dataList.push([
  468. index + 1,
  469. item.name,
  470. item.socialCode,
  471. item.account,
  472. item.legalPerson,
  473. item.contacts,
  474. item.contactsMobile,
  475. item.statusText,
  476. item.createdAt,
  477. ]);
  478. });
  479. dataConversionUtil.dataToExcel("供应商列表", tableHeader, dataList);
  480. this.$message.success("导出成功!");
  481. }, 1000);
  482. },
  483. success() {
  484. let ids = Array.from(this.multipleSelection, ({
  485. id
  486. }) => id);
  487. let status = Array.from(this.multipleSelection, ({
  488. status
  489. }) => status)
  490. if(status.includes(1)) {
  491. this.$message({
  492. type: 'error',
  493. message: '未认证的选项不能在此认证失败'
  494. })
  495. }else if(ids==""){
  496. this.$message({
  497. type: 'error',
  498. message: '请选择数据'
  499. })
  500. }else{
  501. this.$request({
  502. url: "/api/Supplier/manage",
  503. method: "post",
  504. data: {
  505. ids: ids,
  506. operateType: 3,
  507. },
  508. }).then((res) => {
  509. if (res.code == 200) {
  510. this.$message({
  511. type: "success",
  512. message: res.msg,
  513. });
  514. this.$refs.multipleTable.clearSelection();
  515. this.getAllList();
  516. } else {
  517. this.$message({
  518. type: "danger",
  519. message: res.msg,
  520. });
  521. this.getAllList();
  522. }
  523. });
  524. }
  525. },
  526. failed() {
  527. let ids = Array.from(this.multipleSelection, ({
  528. id
  529. }) => id);
  530. let status = Array.from(this.multipleSelection, ({
  531. status
  532. }) => status)
  533. if (status.includes(0)) {
  534. this.$message({
  535. type: 'error',
  536. message: '未认证的选项不能在此认证失败'
  537. })
  538. }else if(ids == ""){
  539. this.$message({
  540. type: 'error',
  541. message: '请选择数据'
  542. })
  543. } else {
  544. this.$request({
  545. url: "/api/Supplier/manage",
  546. method: "post",
  547. data: {
  548. ids: ids,
  549. operateType: 4,
  550. },
  551. }).then((res) => {
  552. if (res.code == 200) {
  553. this.$message({
  554. type: "success",
  555. message: res.msg,
  556. });
  557. this.$refs.multipleTable.clearSelection();
  558. this.getAllList();
  559. } else {
  560. this.$message({
  561. type: "danger",
  562. message: res.msg,
  563. });
  564. this.getAllList();
  565. }
  566. });
  567. }
  568. },
  569. recover() {
  570. let ids = Array.from(this.multipleSelection, ({
  571. id
  572. }) => id);
  573. let status = Array.from(this.multipleSelection, ({
  574. isDeleted
  575. }) => isDeleted)
  576. if (status.includes(0)) {
  577. this.$message({
  578. type: 'error',
  579. message: '不能恢复已是正常状态的账号'
  580. })
  581. } else if (ids == "") {
  582. this.$message({
  583. type: 'error',
  584. message: '请选择数据'
  585. })
  586. } else {
  587. this.$request({
  588. url: "/api/Supplier/manage",
  589. method: "post",
  590. data: {
  591. ids: ids,
  592. operateType: 2,
  593. },
  594. }).then((res) => {
  595. if (res.code == 200) {
  596. this.$message({
  597. type: "success",
  598. message: res.msg,
  599. });
  600. this.$refs.multipleTable.clearSelection();
  601. this.getAllList();
  602. } else {
  603. this.$message({
  604. type: "danger",
  605. message: res.msg,
  606. });
  607. this.getAllList();
  608. }
  609. });
  610. }
  611. },
  612. Srecover(id) {
  613. this.$request({
  614. url: "/api/Supplier/manage",
  615. method: "post",
  616. data: {
  617. ids: [id],
  618. operateType: 2,
  619. },
  620. }).then((res) => {
  621. if (res.code == 200) {
  622. this.$message({
  623. type: "success",
  624. message: res.msg,
  625. });
  626. this.getAllList();
  627. } else {
  628. this.$message({
  629. type: "danger",
  630. message: res.msg,
  631. });
  632. this.getAllList();
  633. }
  634. });
  635. },
  636. deleted() {
  637. let ids = Array.from(this.multipleSelection, ({
  638. id
  639. }) => id);
  640. let status = Array.from(this.multipleSelection, ({
  641. isDeleted
  642. }) => isDeleted)
  643. if (status.includes(1)) {
  644. this.$message({
  645. type: 'error',
  646. message: '不能删除已是删除状态的账号'
  647. })
  648. } else if (ids == "") {
  649. this.$message({
  650. type: 'error',
  651. message: '请选择数据'
  652. })
  653. } else {
  654. this.$request({
  655. url: "/api/Supplier/manage",
  656. method: "post",
  657. data: {
  658. ids: ids,
  659. operateType: 1,
  660. },
  661. }).then((res) => {
  662. if (res.code == 200) {
  663. this.$message({
  664. type: "success",
  665. message: res.msg,
  666. });
  667. this.$refs.multipleTable.clearSelection();
  668. this.getAllList();
  669. } else {
  670. this.$message({
  671. type: "danger",
  672. message: res.msg,
  673. });
  674. this.getAllList();
  675. }
  676. });
  677. }
  678. },
  679. Sdeleted(id) {
  680. this.$request({
  681. url: "/api/Supplier/manage",
  682. method: "post",
  683. data: {
  684. ids: [id],
  685. operateType: 1,
  686. },
  687. }).then((res) => {
  688. if (res.code == 200) {
  689. this.$message({
  690. type: "success",
  691. message: res.msg,
  692. });
  693. this.getAllList();
  694. } else {
  695. this.$message({
  696. type: "danger",
  697. message: res.msg,
  698. });
  699. this.getAllList();
  700. }
  701. });
  702. },
  703. reset(id) {
  704. this.dialogVisible = true;
  705. this.password.supplierId = id;
  706. },
  707. // 提交修改密码
  708. onSubmit() {
  709. if (this.password.newpassword !== this.password.ConfirmnewPassword) {
  710. this.$message({
  711. type: "error",
  712. message: "密码与确认密码不一致",
  713. });
  714. } else if (
  715. this.password.newpassword.length < 6 ||
  716. this.password.ConfirmnewPassword < 6
  717. ) {
  718. this.$message({
  719. type: "error",
  720. message: "密码与确认密码至少6位",
  721. });
  722. } else {
  723. this.$request({
  724. url: "/api/Account/password/resetSupplier",
  725. method: "post",
  726. data: {
  727. password: this.password.newpassword,
  728. supplierId: this.password.supplierId,
  729. },
  730. }).then((res) => {
  731. console.log(res);
  732. if (res.code === 200) {
  733. this.$message({
  734. type: "success",
  735. message: "重置成功",
  736. });
  737. this.dialogVisible = false;
  738. }
  739. });
  740. }
  741. },
  742. },
  743. };
  744. </script>
  745. <style lang="scss" scoped>
  746. .pulldown {
  747. width: 185px;
  748. height: 40px;
  749. border: 1px solid #e8e8e8;
  750. border-radius: 10px;
  751. display: flex;
  752. justify-content: center;
  753. align-items: center;
  754. justify-content: space-between;
  755. padding: 0 20px;
  756. color: #999999;
  757. }
  758. .pagesip {
  759. width: 100%;
  760. margin: 20px auto;
  761. display: flex;
  762. // align-items: center;
  763. justify-content: flex-end;
  764. }
  765. .el-pagination.is-background .el-pager li:not(.disabled).active {
  766. background-color: #d8ab5a;
  767. }
  768. .el-col {
  769. margin-bottom: 20px;
  770. }
  771. .btn {
  772. padding: 20px;
  773. }
  774. </style>