supply.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <div>
  3. <Card style="width:100%" :bordered="false" :dis-hover="true" v-show="!addShow && !editShow">
  4. <p slot="title">供应商列表</p>
  5. <div slot="extra">
  6. <Button @click="newGys" v-if="buttonShow.add">新增供应商</Button>
  7. <Button @click="exportList" v-if="buttonShow.export">导出明细</Button>
  8. <!-- <Button @click="editShow = true">测试----编辑</Button> -->
  9. </div>
  10. <Row :gutter="10" style="margin-bottom: 10px">
  11. <Col span="4">
  12. <Select
  13. clearable
  14. v-model="searchForm.ssqy"
  15. placeholder="所属区域"
  16. @on-change="ssqyChange"
  17. multiple
  18. >
  19. <Option
  20. v-for="item in ssqyList"
  21. :value="item.areaId"
  22. :key="item.areaId"
  23. >{{ item.areaName }}</Option>
  24. </Select>
  25. </Col>
  26. <Col span="4">
  27. <Select clearable v-model="searchForm.gysfl" placeholder="供应商分类">
  28. <Option
  29. v-for="item in gysflList"
  30. :value="item.detailId"
  31. :key="item.detailId"
  32. >{{ item.detailName }}</Option>
  33. </Select>
  34. </Col>
  35. <Col span="4">
  36. <Select clearable v-model="searchForm.gyspj" placeholder="供应商评级">
  37. <Option
  38. v-for="item in gyspjList"
  39. :value="item.detailId"
  40. :key="item.detailId"
  41. >{{ item.detailName }}</Option>
  42. </Select>
  43. </Col>
  44. <Col span="4">
  45. <Input v-model="searchForm.gysbh" placeholder="供应商编号" />
  46. </Col>
  47. <Col span="4">
  48. <Input v-model="searchForm.gysmc" placeholder="供应商名称" />
  49. </Col>
  50. <Col span="4">
  51. <Input v-model="searchForm.lxr" placeholder="供应商联系人或联系电话" />
  52. </Col>
  53. </Row>
  54. <Row :gutter="10" style="margin-bottom: 10px">
  55. <Col span="4">
  56. <Select clearable filterable v-model="searchForm.fgcgy" placeholder="分管采购员">
  57. <Option
  58. v-for="item in fgcgyList"
  59. :value="item.userId"
  60. :key="item.userId"
  61. >{{ item.userName }}</Option>
  62. </Select>
  63. </Col>
  64. <Col span="4">
  65. <Select clearable v-model="searchForm.qyzt" placeholder="启用状态">
  66. <Option v-for="item in qyztList" :value="item.value" :key="item.value">{{ item.label }}</Option>
  67. </Select>
  68. </Col>
  69. <Col span="4">
  70. <Button type="primary" style="width: 80px" @click="searchTableData">查询</Button>
  71. </Col>
  72. </Row>
  73. <Table
  74. :columns="tableColumn"
  75. style="width: 100%"
  76. :data="tableData"
  77. :height="resizeHeight - 65"
  78. :loading="tableLoading"
  79. @on-row-dblclick="goDetail"
  80. >
  81. <template slot-scope="{ row, index }" slot="gpEnabledState">
  82. <span>{{ row.gpEnabledState == "1" ? "未启用" : "启用"}}</span>
  83. </template>
  84. <template slot-scope="{ row, index }" slot="action">
  85. <div>
  86. <a
  87. href="javascript:;"
  88. v-if="buttonShow.edit"
  89. @click="editRow(row.gpId, row.gpInfoType)"
  90. >编辑</a>
  91. <a
  92. v-if="buttonShow.delete && row.gpInfoType == 1"
  93. href="javascript:;"
  94. @click="deleteRow(row.gpId)"
  95. >删除</a>
  96. </div>
  97. </template>
  98. </Table>
  99. <Page align="right" :current="pageNum" @on-change="pageChange" :total="pageTotal" show-total />
  100. </Card>
  101. <supplyAdd
  102. ref="add"
  103. :ssqyList="ssqyList"
  104. :gysflList="gysflList"
  105. :gyspjList="gyspjList"
  106. :fgcgyList="fgcgyList"
  107. @return="() => {addShow = false ; this.getTableData()}"
  108. v-show="addShow"
  109. />
  110. <supplyEdit
  111. ref="edit"
  112. :buttonShow="buttonShow"
  113. :ssqyList="ssqyList"
  114. :gysflList="gysflList"
  115. :gyspjList="gyspjList"
  116. :fgcgyList="fgcgyList"
  117. :gp-id="editId"
  118. :canBeEdit="canBeEdit"
  119. @return="() => {editShow = false ; this.getTableData()}"
  120. v-show="editShow"
  121. />
  122. </div>
  123. </template>
  124. <script>
  125. import supplyAdd from "./components/supply/supplyAdd";
  126. import supplyEdit from "./components/supply/supplyEdit";
  127. import {
  128. goodProviderPageList,
  129. deleteGoodProvider,
  130. getDictInfoList,
  131. exportGoodProviderInfo,
  132. getJobList,
  133. getAreaList,
  134. getUserButtons
  135. } from "@/service/getData";
  136. export default {
  137. name: "supply",
  138. components: {
  139. supplyAdd,
  140. supplyEdit
  141. },
  142. data() {
  143. return {
  144. canBeEdit: true,
  145. addShow: false,
  146. editShow: false,
  147. // 详情参数
  148. editId: "",
  149. // 分页
  150. pageTotal: 0,
  151. pageNum: 1,
  152. // 自适应尺寸↓
  153. resizeHeight: 100,
  154. resizeWidth: 100,
  155. handleWidth: 100,
  156. buttonShow: {
  157. add: false,
  158. edit: false,
  159. delete: false,
  160. export: false,
  161. addPrice: false,
  162. deletePrice: false,
  163. editPrice: false
  164. },
  165. // 查询参数
  166. searchForm: {
  167. ssqy: [], //所属区域
  168. gysfl: "", //供应商分类
  169. gyspj: "", //供应商评级
  170. gysbh: "", //供应商编号
  171. gysmc: "", //供应商名称
  172. lxr: "", //供应商联系人or电话
  173. fgcgy: "", //分管采购员
  174. qyzt: "" //启用状态
  175. },
  176. ssqyList: [],
  177. gysflList: [],
  178. gyspjList: [],
  179. fgcgyList: [],
  180. qyztList: [
  181. { label: "未启用", value: "1" },
  182. { label: "启用", value: "0" }
  183. ],
  184. // 表格参数
  185. tableLoading: false,
  186. tableColumn: [
  187. {
  188. title: "操作",
  189. slot: "action",
  190. width: 100
  191. },
  192. {
  193. title: "供应商编码",
  194. key: "gpNumber",
  195. tooltip: "true",
  196. width: 100
  197. },
  198. {
  199. title: "供应商名称",
  200. key: "gpName",
  201. tooltip: "true",
  202. width: 200
  203. },
  204. {
  205. title: "供应商简称",
  206. key: "gpAbbreviation",
  207. tooltip: "true"
  208. },
  209. {
  210. title: "联系人",
  211. key: "gpLinker",
  212. tooltip: "true"
  213. },
  214. {
  215. title: "联系电话",
  216. key: "gpLinkTell",
  217. tooltip: "true"
  218. },
  219. // {
  220. // title: "供应商分类",
  221. // key: "gpClassifyName",
  222. // tooltip: "true"
  223. // },
  224. // {
  225. // title: "供应商评级",
  226. // key: "gpGradeName",
  227. // tooltip: "true"
  228. // },
  229. {
  230. title: "所属区域",
  231. key: "gpRegionName",
  232. tooltip: "true"
  233. },
  234. {
  235. title: "分管采购员",
  236. key: "gpBuyerName",
  237. tooltip: "true"
  238. },
  239. {
  240. title: "启用状态",
  241. slot: "gpEnabledState",
  242. tooltip: "true"
  243. },
  244. {
  245. title: "创建或同步时间",
  246. key: "createDate",
  247. tooltip: "true",
  248. width: 150
  249. }
  250. ],
  251. tableData: []
  252. };
  253. },
  254. created() {
  255. this.getTableData();
  256. this.getUserAuth();
  257. getAreaList(localStorage.user_id).then(res => {
  258. this.ssqyList = res.items;
  259. });
  260. getJobList().then(res => {
  261. if (res.status == 200) {
  262. this.fgcgyList = res.data;
  263. } else {
  264. this.$Message.error("获取分管采购员列表失败!");
  265. }
  266. });
  267. getDictInfoList(1).then(res => {
  268. this.gysflList = res.data;
  269. });
  270. getDictInfoList(2).then(res => {
  271. this.gyspjList = res.data;
  272. });
  273. },
  274. methods: {
  275. //获取按钮权限
  276. getUserAuth() {
  277. //获取用户在当前页面的权限
  278. var self = this;
  279. let menuId = sessionStorage.getItem("refresh_child_id");
  280. let userForm = {
  281. userId: localStorage.user_id,
  282. menuId: menuId
  283. };
  284. let buttons = [
  285. "add",
  286. "edit",
  287. "delete",
  288. "export",
  289. "addPrice",
  290. "deletePrice",
  291. "editPrice"
  292. ];
  293. getUserButtons(userForm).then(result => {
  294. if (result.resultCode == "200") {
  295. result.data.forEach(item => {
  296. // item.code
  297. if (buttons.includes(item.code)) {
  298. self.buttonShow[item.code] = true;
  299. }
  300. });
  301. }
  302. });
  303. },
  304. goDetail(row, index) {
  305. // this.editRow(row.gpId, row.gpInfoType,false)
  306. this.editRow(row.gpId, row.gpInfoType);
  307. //参考跳转
  308. // window.open(
  309. // `https://test.hajwy.com/purchase-web/#/viewPurchaseApply?id=${row.id}`
  310. // );
  311. // window.open(`/#/viewPurchaseApply?id=${row.id}`);
  312. },
  313. resizePage() {
  314. this.resizeHeight = window.innerHeight - 282;
  315. this.resizeWidth = window.innerWidth;
  316. // this.handleWidth = this.$refs.handleHolder.offsetWidth;
  317. },
  318. ssqyChange(val) {
  319. if (val.indexOf("all") != -1) {
  320. this.searchForm.ssqy = ["all"];
  321. }
  322. },
  323. glxmChange(val) {
  324. if (val.indexOf("all") != -1) {
  325. this.searchForm.glxm = ["all"];
  326. }
  327. },
  328. //导出明细
  329. exportList() {
  330. let postData = {
  331. queryText: this.searchForm.lxr,
  332. gpName: this.searchForm.gysmc,
  333. gpNumber: this.searchForm.gysbh,
  334. gpClassifyId: this.searchForm.gysfl,
  335. gpGradeId: this.searchForm.gyspj,
  336. gpEnabledState: this.searchForm.qyzt,
  337. gpBuyerId: this.searchForm.fgcgy,
  338. gpRegionIds:
  339. this.searchForm.ssqy[0] == "all"
  340. ? this.ssqyList
  341. : this.searchForm.ssqy
  342. };
  343. exportGoodProviderInfo(postData);
  344. },
  345. //供应商详情,默认可编辑
  346. editRow(id, type, canBeEdit = true) {
  347. if (type == "2") {
  348. this.$refs.edit.editing = false;
  349. this.$refs.edit.canEdit = false;
  350. }
  351. this.editId = id;
  352. this.editShow = true;
  353. this.canBeEdit = canBeEdit;
  354. this.$refs.edit.getGys();
  355. },
  356. //删除供应商
  357. deleteRow(id) {
  358. this.$Modal.confirm({
  359. title: "删除",
  360. content: "是否确定删除该供应商?",
  361. okText: "确定",
  362. onOk: () => {
  363. deleteGoodProvider(id).then(res => {
  364. if ((res.status = 200)) {
  365. this.$Message.success("删除成功!");
  366. this.getTableData();
  367. }
  368. });
  369. }
  370. });
  371. },
  372. //新增供应商
  373. newGys() {
  374. this.addShow = true;
  375. this.$refs.add.initData();
  376. },
  377. //列表方法
  378. getTableData() {
  379. let data = {
  380. queryText: this.searchForm.lxr,
  381. gpName: this.searchForm.gysmc,
  382. gpNumber: this.searchForm.gysbh,
  383. gpClassifyId: this.searchForm.gysfl,
  384. gpGradeId: this.searchForm.gyspj,
  385. gpEnabledState: this.searchForm.qyzt,
  386. gpBuyerId: this.searchForm.fgcgy,
  387. gpRegionIds:
  388. this.searchForm.ssqy[0] == "all"
  389. ? this.ssqyList
  390. : this.searchForm.ssqy
  391. };
  392. let pageStr = 10 + "/" + this.pageNum;
  393. this.tableLoading = true;
  394. goodProviderPageList(data, pageStr).then(res => {
  395. console.log(res);
  396. if (res.status == 200) {
  397. this.tableData = res.data.records;
  398. this.pageTotal = res.data.total;
  399. } else {
  400. this.$Message.error("获取供应商信息失败。");
  401. }
  402. this.tableLoading = false;
  403. });
  404. },
  405. searchTableData() {
  406. this.pageNum = 1;
  407. this.getTableData();
  408. },
  409. //分页页码回调
  410. pageChange(page) {
  411. this.pageNum = page;
  412. this.getTableData();
  413. }
  414. },
  415. mounted: function() {
  416. // 监听浏览器页面尺寸
  417. window.addEventListener("resize", this.resizePage);
  418. this.resizePage();
  419. }
  420. };
  421. </script>
  422. <style lang="scss" scoped>
  423. ivu-card-head-inner,
  424. .ivu-card-head p {
  425. display: inline-block;
  426. width: 100%;
  427. height: 20px;
  428. line-height: 20px;
  429. font-size: 14px;
  430. color: #17233d;
  431. font-weight: 700;
  432. overflow: hidden;
  433. text-overflow: ellipsis;
  434. white-space: nowrap;
  435. font-weight: normal;
  436. }
  437. </style>