purchaseOrder.vue 18 KB

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