purchaseOrder.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. <template>
  2. <div>
  3. <Card style="width:100%" :bordered="false" :dis-hover="true" v-show="!addShow && !printShow">
  4. <p slot="title">采购订单列表</p>
  5. <div slot="extra">
  6. <Button @click="addOrderShow" v-if="buttonShow.add">新增采购订单</Button>
  7. <Button @click="exportData" v-if="buttonShow.export">导出明细</Button>
  8. <!-- <Button @click="printShow = true">打印---测试</Button> -->
  9. </div>
  10. <Row :gutter="10" style="margin-bottom: 10px">
  11. <Col span="4">
  12. <Select clearable v-model="searchForm.ssqy" placeholder="所属区域" @on-change="ssqyChange">
  13. <Option
  14. v-for="item in ssqyList"
  15. :value="item.areaId"
  16. :key="item.areaId"
  17. >{{ item.areaName }}</Option>
  18. </Select>
  19. </Col>
  20. <Col span="4">
  21. <Select clearable v-model="searchForm.glxm" placeholder="关联项目" @on-change="glxmChange">
  22. <Option
  23. v-for="item in glxmList"
  24. :value="item.projectId"
  25. :key="item.projectId"
  26. >{{ item.projectName }}</Option>
  27. </Select>
  28. </Col>
  29. <Col span="4">
  30. <Input v-model="searchForm.cgr" placeholder="采购人" />
  31. </Col>
  32. <Col span="4">
  33. <DatePicker
  34. format="yyyy-MM-dd HH:mm:ss"
  35. :value="searchForm.xdsj"
  36. @on-change="dateChange"
  37. type="datetimerange"
  38. placeholder="下单时间"
  39. ></DatePicker>
  40. </Col>
  41. <Col span="4">
  42. <DatePicker
  43. format="yyyy-MM-dd HH:mm:ss"
  44. :value="searchForm.jhsj"
  45. @on-change="dateChange1"
  46. type="daterange"
  47. placeholder="交货时间"
  48. ></DatePicker>
  49. </Col>
  50. </Row>
  51. <Row :gutter="10" style="margin-bottom: 10px">
  52. <Col span="4">
  53. <Input v-model="searchForm.shr" placeholder="收货人" />
  54. </Col>
  55. <Col span="4">
  56. <Select clearable v-model="searchForm.gys" filterable placeholder="供应商">
  57. <Option v-for="item in gysList" :value="item.gpId" :key="item.gpId">{{ item.gpName }}</Option>
  58. </Select>
  59. </Col>
  60. <Col span="4">
  61. <Select clearable v-model="searchForm.spzt" placeholder="审批状态">
  62. <Option v-for="item in spztList" :value="item.value" :key="item.value">{{ item.label }}</Option>
  63. </Select>
  64. </Col>
  65. <Col span="4">
  66. <Select clearable v-model="searchForm.ddzt" placeholder="订单状态">
  67. <Option v-for="item in ddztList" :value="item.value" :key="item.value">{{ item.label }}</Option>
  68. </Select>
  69. </Col>
  70. <Col span="4">
  71. <Input v-model="searchForm.title" placeholder="订购编号/标题/申购单号/物料名称" />
  72. </Col>
  73. <Col span="4">
  74. <Button type="primary" style="width: 80px" @click="pageNum = 1 ;getTableData()">查询</Button>
  75. </Col>
  76. </Row>
  77. <Table
  78. style="width:100%"
  79. :columns="tableColumn"
  80. :data="tableData"
  81. :height="resizeHeight - 65"
  82. :loading="tableLoading"
  83. @on-select="tableOnSelect"
  84. @on-row-dblclick="goDetail"
  85. highlight-row
  86. >
  87. <template slot-scope="{ row, index }" slot="approvalState">
  88. <div>
  89. <span v-if="row.approvalState == '1'">未提交</span>
  90. <span v-if="row.approvalState == '2'">审核中</span>
  91. <span v-if="row.approvalState == '3'">审核通过</span>
  92. <span v-if="row.approvalState == '4'">审核拒绝</span>
  93. </div>
  94. </template>
  95. <template slot-scope="{ row, index }" slot="orderState">
  96. <div>
  97. <span v-if="row.orderState == '1'">未下单</span>
  98. <span v-if="row.orderState == '2'">待下单</span>
  99. <span v-if="row.orderState == '3'">已下单</span>
  100. <span v-if="row.orderState == '4'">入库中</span>
  101. <span v-if="row.orderState == '5'">已入库</span>
  102. <span v-if="row.orderState == '6'">已取消</span>
  103. </div>
  104. </template>
  105. <template slot-scope="{ row, index }" slot="action">
  106. <div>
  107. <a href="javascript:;" v-if="buttonShow.check" @click="checkRow(row)">{{ '查看' }}</a>
  108. <a
  109. href="javascript:;"
  110. @click="editRow(row)"
  111. v-if="buttonShow.edit && row.creator == userId"
  112. >{{ '编辑' }}</a>
  113. <a
  114. href="javascript:;"
  115. v-if="buttonShow.submit && row.approvalState == '1' && row.creator == userId"
  116. @click="submitRow(row.orderId)"
  117. >提交</a>
  118. <a
  119. href="javascript:;"
  120. v-if="buttonShow.delete && row.approvalState == '1' && row.creator == userId"
  121. @click="deleteRow(row)"
  122. >删除</a>
  123. <a
  124. href="javascript:;"
  125. v-if="buttonShow.print && row.orderState != '6'"
  126. @click="printRow(row)"
  127. >打印</a>
  128. <a
  129. href="javascript:;"
  130. @click="cgddxd(row.orderId)"
  131. v-if="buttonShow.order && row.orderState == '2'"
  132. >下单</a>
  133. <!-- <a href="javascript:;" @click="cgddqx(row.orderId)" v-if="row.orderState == '2'">取消订单</a> -->
  134. </div>
  135. </template>
  136. </Table>
  137. <Page align="right" :current="pageNum" :total="pageTotal" @on-change="pageChange" show-total />
  138. </Card>
  139. <orderAdd
  140. ref="add"
  141. :glqyList="ssqyList"
  142. @return="() => {addShow = false; getTableData()}"
  143. v-show="addShow"
  144. />
  145. <orderPrint ref="print" @return="() => {printShow = false; getTableData()}" v-show="printShow" />
  146. </div>
  147. </template>
  148. <script>
  149. import {
  150. getPurchaseOrder,
  151. deletePurchaseOrder,
  152. findPurchaseOrder,
  153. selectGoodProviderSelectionList,
  154. exportPurchaseOrder,
  155. getAreaList,
  156. getProjectList,
  157. editPurchaseOrderState,
  158. submitPurchaseOrder,
  159. getUserButtons,
  160. } from "@/service/getData";
  161. import orderAdd from "./components/order/orderAdd";
  162. import orderPrint from "./components/order/orderPrint";
  163. export default {
  164. name: "purchaseOrder",
  165. components: {
  166. orderAdd,
  167. orderPrint,
  168. },
  169. data() {
  170. return {
  171. addShow: false,
  172. printShow: false,
  173. userId: localStorage.user_id,
  174. // 自适应尺寸↓
  175. resizeHeight: 100,
  176. resizeWidth: 100,
  177. handleWidth: 100,
  178. buttonShow: {
  179. check: false,
  180. add: false,
  181. submit: false,
  182. export: false,
  183. order: false,
  184. edit: false,
  185. delete: false,
  186. print: false,
  187. },
  188. // 查询参数
  189. searchForm: {
  190. ssqy: "", //所属区域
  191. glxm: "", //关联项目
  192. glcgjh: "", //关联采购计划
  193. cgr: "", //采购人
  194. xdsj: [], //下单时间
  195. jhsj: [], //交货时间
  196. shr: "", //收货人
  197. gys: "", //供应商
  198. spzt: "", //审批状态
  199. ddzt: "", //订单状态
  200. title: "", //订单编号或标题
  201. },
  202. ssqyList: [],
  203. glxmList: [],
  204. glcgjhList: [],
  205. cgrList: [],
  206. shrList: [],
  207. gysList: [],
  208. spztList: [
  209. { value: 1, label: "未提交" },
  210. { value: 2, label: "审核中" },
  211. { value: 3, label: "审核通过" },
  212. { value: 4, label: "审核拒绝" },
  213. ],
  214. ddztList: [
  215. { value: 1, label: "未下单" },
  216. { value: 2, label: "待下单" },
  217. { value: 3, label: "已下单" },
  218. { value: 4, label: "入库中" },
  219. { value: 5, label: "已入库" },
  220. { value: 6, label: "已取消" },
  221. ],
  222. // 表格参数
  223. tableLoading: false,
  224. pageTotal: 0,
  225. pageNum: 1,
  226. tableColumn: [
  227. // {
  228. // type: "selection",
  229. // width: 60,
  230. // align: "center"
  231. // },
  232. {
  233. title: "操作",
  234. slot: "action",
  235. width: 180,
  236. },
  237. {
  238. title: "订购编号",
  239. key: "orderCode",
  240. tooltip: true,
  241. width: 200,
  242. },
  243. {
  244. title: "标题",
  245. key: "title",
  246. tooltip: true,
  247. width: 250,
  248. },
  249. {
  250. title: "审批状态",
  251. slot: "approvalState",
  252. tooltip: true,
  253. width: 100,
  254. },
  255. {
  256. title: "状态",
  257. slot: "orderState",
  258. tooltip: true,
  259. width: 100,
  260. },
  261. {
  262. title: "总价(元)",
  263. key: "totalPrice",
  264. tooltip: true,
  265. width: 100,
  266. },
  267. {
  268. title: "申请人",
  269. key: "applicantName",
  270. tooltip: true,
  271. width: 200,
  272. },
  273. {
  274. title: "分管采购员",
  275. key: "purchaserName",
  276. tooltip: true,
  277. width: 200,
  278. },
  279. {
  280. title: "申请时间",
  281. key: "applicantTime",
  282. tooltip: true,
  283. width: 180,
  284. },
  285. {
  286. title: "所属区域",
  287. key: "areaName",
  288. tooltip: true,
  289. width: 100,
  290. },
  291. {
  292. title: "关联项目",
  293. key: "projectName",
  294. tooltip: true,
  295. width: 100,
  296. },
  297. ],
  298. tableData: [],
  299. };
  300. },
  301. created() {
  302. this.getTableData();
  303. this.getUserAuth();
  304. getAreaList(localStorage.user_id).then((res) => {
  305. this.ssqyList = res.items;
  306. });
  307. selectGoodProviderSelectionList().then((res) => {
  308. this.gysList = res.data;
  309. });
  310. },
  311. methods: {
  312. dateChange(val, value) {
  313. if (value == "date") {
  314. this.searchForm.xdsj = [val[0], val[1].replace("00:00:00", "23:59:59")];
  315. } else {
  316. this.searchForm.xdsj = val;
  317. }
  318. },
  319. dateChange1(val, value) {
  320. if (value == "date") {
  321. this.searchForm.jhsj = [val[0], val[1].replace("00:00:00", "23:59:59")];
  322. } else {
  323. this.searchForm.jhsj = val;
  324. }
  325. },
  326. //获取按钮权限
  327. getUserAuth() {
  328. //获取用户在当前页面的权限
  329. var self = this;
  330. let menuId = sessionStorage.getItem("refresh_child_id");
  331. let userForm = {
  332. userId: localStorage.user_id,
  333. menuId: menuId,
  334. };
  335. let buttons = [
  336. "check",
  337. "add",
  338. "submit",
  339. "export",
  340. "order",
  341. "edit",
  342. "delete",
  343. "print",
  344. ];
  345. getUserButtons(userForm).then((result) => {
  346. if (result.resultCode == "200") {
  347. result.data.forEach((item) => {
  348. // item.code
  349. if (buttons.includes(item.code)) {
  350. self.buttonShow[item.code] = true;
  351. }
  352. });
  353. }
  354. });
  355. },
  356. goDetail(row) {
  357. // if (this.buttonShow.edit) {
  358. // this.editRow(row);
  359. // }
  360. let routeUrl = this.$router.resolve({
  361. path: "/viewPurchaseOrder",
  362. query: {
  363. id: row.orderId,
  364. },
  365. });
  366. window.open(routeUrl.href, "_blank");
  367. // window.open(
  368. // `https://test.hajwy.com/purchase-web/#/viewPurchaseOrder?id=${row.orderId}`
  369. // );
  370. // window.open(`/#/viewPurchaseOrder?id=${row.orderId}`)
  371. },
  372. resizePage() {
  373. this.resizeHeight = window.innerHeight - 282;
  374. this.resizeWidth = window.innerWidth;
  375. // this.handleWidth = this.$refs.handleHolder.offsetWidth;
  376. },
  377. ssqyChange(val) {
  378. let postData = {
  379. areaId: this.searchForm.ssqy,
  380. userId: localStorage.user_id,
  381. };
  382. getProjectList(postData).then((res) => {
  383. this.searchForm.glxm = "";
  384. this.glxmList = res.items;
  385. });
  386. },
  387. glxmChange(val) {},
  388. pageChange(val) {
  389. this.pageNum = val;
  390. this.getTableData();
  391. },
  392. exportData() {
  393. let allArea = [];
  394. let allProject = [];
  395. let areaList = JSON.parse(localStorage.getItem("areaList"));
  396. let projectList = JSON.parse(localStorage.getItem("projectList"));
  397. areaList.forEach((a) => allArea.push(a.areaId));
  398. projectList.forEach((a) => allProject.push(a.projectId));
  399. let postData = {
  400. areaIds: `${this.searchForm.ssqy}`,
  401. projectIds: `${this.searchForm.glxm}`,
  402. purchaserName: this.searchForm.cgr,
  403. startTime: this.searchForm.xdsj[0],
  404. endTime: this.searchForm.xdsj[1],
  405. deliveryStartTime: this.searchForm.jhsj[0],
  406. deliveryEndTime: this.searchForm.jhsj[1],
  407. receivedName: this.searchForm.shr,
  408. gpId: this.searchForm.gys,
  409. approvalState: this.searchForm.spzt,
  410. orderState: this.searchForm.ddzt,
  411. queryText: this.searchForm.title,
  412. };
  413. if (!this.searchForm.ssqy) {
  414. postData.areaIds = allArea.join(",");
  415. }
  416. if (!this.searchForm.glxm) {
  417. postData.projectIds = allProject.join(",");
  418. }
  419. exportPurchaseOrder(postData);
  420. },
  421. //列表方法
  422. getTableData() {
  423. let allArea = [];
  424. let allProject = [];
  425. let areaList = JSON.parse(localStorage.getItem("areaList"));
  426. let projectList = JSON.parse(localStorage.getItem("projectList"));
  427. areaList.forEach((a) => allArea.push(a.areaId));
  428. projectList.forEach((a) => allProject.push(a.projectId));
  429. let postData = {
  430. page: this.pageNum,
  431. pageSize: 10,
  432. areaIds: `${this.searchForm.ssqy}`,
  433. projectIds: `${this.searchForm.glxm}`,
  434. purchaserName: this.searchForm.cgr,
  435. startTime: this.searchForm.xdsj[0],
  436. endTime: this.searchForm.xdsj[1],
  437. deliveryStartTime: this.searchForm.jhsj[0],
  438. deliveryEndTime: this.searchForm.jhsj[1],
  439. receivedName: this.searchForm.shr,
  440. gpId: this.searchForm.gys,
  441. approvalState: this.searchForm.spzt,
  442. orderState: this.searchForm.ddzt,
  443. queryText: this.searchForm.title,
  444. };
  445. if (!this.searchForm.ssqy) {
  446. postData.areaIds = allArea.join(",");
  447. }
  448. if (!this.searchForm.glxm) {
  449. postData.projectIds = allProject.join(",");
  450. }
  451. this.tableLoading = true;
  452. getPurchaseOrder(postData).then((res) => {
  453. this.tableLoading = false;
  454. if (res.status == 200) {
  455. this.tableData = res.data.records;
  456. this.pageTotal = res.data.total;
  457. } else {
  458. this.$Message.error("获取采购订单列表失败。");
  459. }
  460. });
  461. },
  462. addOrderShow() {
  463. this.addShow = true;
  464. let date = new Date();
  465. let year = date.getFullYear();
  466. let month =
  467. date.getMonth() + 1 < 10
  468. ? "0" + (date.getMonth() + 1)
  469. : date.getMonth() + 1;
  470. let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  471. let hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
  472. let minute =
  473. date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
  474. let second =
  475. date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  476. let dateArr = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
  477. this.$refs.add.form.xdrq = dateArr;
  478. },
  479. checkRow(row) {
  480. let routeUrl = this.$router.resolve({
  481. path: "/viewPurchaseOrder",
  482. query: {
  483. id: row.orderId,
  484. },
  485. });
  486. window.open(routeUrl.href, "_blank");
  487. },
  488. editRow(row) {
  489. this.addShow = true;
  490. this.$refs.add.getCgddXq(row.orderId);
  491. },
  492. submitRow(id) {
  493. this.$Modal.confirm({
  494. title: "提交",
  495. content: "是否确定提交该采购订单?",
  496. okText: "确定",
  497. onOk: () => {
  498. let postData = {
  499. orderId: id,
  500. };
  501. submitPurchaseOrder(postData).then((res) => {
  502. if (res.status == 200) {
  503. this.$Message.success("提交成功!");
  504. this.getTableData();
  505. } else {
  506. this.$Message.error(res.message);
  507. }
  508. });
  509. },
  510. });
  511. },
  512. cgddxd(id) {
  513. this.$Modal.confirm({
  514. title: "下单",
  515. content: "是否确定下单?",
  516. okText: "确定",
  517. onOk: () => {
  518. let str = `?orderId=${id}&state=3`;
  519. editPurchaseOrderState(str).then((res) => {
  520. if ((res.status = 200)) {
  521. this.$Message.success("下单成功!");
  522. this.getTableData();
  523. }
  524. });
  525. },
  526. });
  527. },
  528. cgddqx(id) {
  529. this.$Modal.confirm({
  530. title: "取消订单",
  531. content: "是否确定取消该订单?",
  532. okText: "确定",
  533. onOk: () => {
  534. let str = `?orderId=${id}&state=6`;
  535. editPurchaseOrderState(str).then((res) => {
  536. if ((res.status = 200)) {
  537. this.$Message.success("取消订单成功!");
  538. this.getTableData();
  539. }
  540. });
  541. },
  542. });
  543. },
  544. deleteRow(row) {
  545. this.$Modal.confirm({
  546. title: "删除",
  547. content: "是否确定删除该采购订单?",
  548. okText: "确定",
  549. onOk: () => {
  550. deletePurchaseOrder(row.orderId).then((res) => {
  551. if ((res.status = 200)) {
  552. this.$Message.success("删除成功!");
  553. this.getTableData();
  554. }
  555. });
  556. },
  557. });
  558. },
  559. printRow(row) {
  560. this.printShow = true;
  561. this.$refs.print.getData(row.orderId);
  562. },
  563. tableOnSelect(selection, row) {},
  564. },
  565. mounted: function () {
  566. // 监听浏览器页面尺寸
  567. window.addEventListener("resize", this.resizePage);
  568. this.resizePage();
  569. },
  570. };
  571. </script>
  572. <style lang="scss" scoped>
  573. ivu-card-head-inner,
  574. .ivu-card-head p {
  575. display: inline-block;
  576. width: 100%;
  577. height: 20px;
  578. line-height: 20px;
  579. font-size: 14px;
  580. color: #17233d;
  581. font-weight: 700;
  582. overflow: hidden;
  583. text-overflow: ellipsis;
  584. white-space: nowrap;
  585. font-weight: normal;
  586. }
  587. </style>