purchaseOrder.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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="addShow = true">新增采购订单</Button>
  7. <Button @click="exportData">导出明细</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"
  35. :value="searchForm.xdsj"
  36. @on-change="searchForm.xdsj=$event"
  37. type="daterange"
  38. placeholder="下单时间"
  39. ></DatePicker>
  40. </Col>
  41. <Col span="4">
  42. <DatePicker
  43. format="yyyy-MM-dd"
  44. :value="searchForm.jhsj"
  45. @on-change="searchForm.jhsj=$event"
  46. type="date"
  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="getTableData">查询</Button>
  75. </Col>
  76. </Row>
  77. <Table
  78. :columns="tableColumn"
  79. style="width: 100%"
  80. :data="tableData"
  81. :height="resizeHeight - 65"
  82. :loading="tableLoading"
  83. @on-select="tableOnSelect"
  84. >
  85. <template slot-scope="{ row, index }" slot="approvalState">
  86. <div>
  87. <span v-if="row.approvalState == '1'">未提交</span>
  88. <span v-if="row.approvalState == '2'">审核中</span>
  89. <span v-if="row.approvalState == '3'">审核通过</span>
  90. <span v-if="row.approvalState == '4'">审核拒绝</span>
  91. </div>
  92. </template>
  93. <template slot-scope="{ row, index }" slot="orderState">
  94. <div>
  95. <span v-if="row.orderState == '1'">未下单</span>
  96. <span v-if="row.orderState == '2'">待下单</span>
  97. <span v-if="row.orderState == '3'">已下单</span>
  98. <span v-if="row.orderState == '4'">入库中</span>
  99. <span v-if="row.orderState == '5'">已入库</span>
  100. <span v-if="row.orderState == '6'">已取消</span>
  101. </div>
  102. </template>
  103. <template slot-scope="{ row, index }" slot="action">
  104. <div>
  105. <a href="javascript:;" @click="editRow(row)">编辑</a>
  106. <a href="javascript:;" v-if="row.orderState == '1'" @click="deleteRow(row)">删除</a>
  107. <a
  108. href="javascript:;"
  109. v-if="row.orderState != '6' || row.approvalState != '4'"
  110. @click="printRow(row)"
  111. >打印</a>
  112. <a href="javascript:;" @click="cgddxd(row.orderId)" v-if="row.orderState == '2'">下单</a>
  113. <a href="javascript:;" @click="cgddqx(row.orderId)" v-if="row.orderState == '2'">取消订单</a>
  114. </div>
  115. </template>
  116. </Table>
  117. <Page align="right" :total="pageTotal" @on-change="pageChange" show-total />
  118. </Card>
  119. <orderAdd
  120. ref="add"
  121. :glqyList="ssqyList"
  122. :gysList="gysList"
  123. @return="() => {addShow = false; getTableData()}"
  124. v-show="addShow"
  125. />
  126. <orderPrint ref="print" @return="() => {printShow = false; getTableData()}" v-show="printShow" />
  127. </div>
  128. </template>
  129. <script>
  130. import {
  131. getPurchaseOrder,
  132. deletePurchaseOrder,
  133. findPurchaseOrder,
  134. selectGoodProviderSelectionList,
  135. exportPurchaseOrder,
  136. getAreaList,
  137. getProjectList,
  138. editPurchaseOrderState,
  139. submitPurchaseOrder
  140. } from "@/service/getData";
  141. import orderAdd from "./components/order/orderAdd";
  142. import orderPrint from "./components/order/orderPrint";
  143. export default {
  144. components: {
  145. orderAdd,
  146. orderPrint
  147. },
  148. data() {
  149. return {
  150. addShow: false,
  151. printShow: false,
  152. // 自适应尺寸↓
  153. resizeHeight: 100,
  154. resizeWidth: 100,
  155. handleWidth: 100,
  156. // 查询参数
  157. searchForm: {
  158. ssqy: [], //所属区域
  159. glxm: [], //关联项目
  160. glcgjh: "", //关联采购计划
  161. cgr: "", //采购人
  162. xdsj: [], //下单时间
  163. jhsj: "", //交货时间
  164. shr: "", //收货人
  165. gys: "", //供应商
  166. spzt: "", //审批状态
  167. ddzt: "", //订单状态
  168. title: "" //订单编号或标题
  169. },
  170. ssqyList: [],
  171. glxmList: [],
  172. glcgjhList: [],
  173. cgrList: [],
  174. shrList: [],
  175. gysList: [],
  176. spztList: [
  177. { value: 1, label: "未提交" },
  178. { value: 2, label: "审核中" },
  179. { value: 3, label: "审核通过" },
  180. { value: 4, label: "审核拒绝" }
  181. ],
  182. ddztList: [
  183. { value: 1, label: "未下单" },
  184. { value: 2, label: "待下单" },
  185. { value: 3, label: "已下单" },
  186. { value: 4, label: "入库中" },
  187. { value: 5, label: "已入库" },
  188. { value: 6, label: "已取消" }
  189. ],
  190. // 表格参数
  191. tableLoading: false,
  192. pageTotal: 0,
  193. pageNum: 1,
  194. tableColumn: [
  195. {
  196. type: "selection",
  197. width: 60,
  198. align: "center"
  199. },
  200. {
  201. title: "订购编号",
  202. key: "orderCode",
  203. tooltip: "true"
  204. },
  205. {
  206. title: "标题",
  207. key: "title",
  208. tooltip: "true"
  209. },
  210. {
  211. title: "总价(元)",
  212. key: "totalPrice",
  213. tooltip: "true"
  214. },
  215. {
  216. title: "申请人",
  217. key: "applicantName",
  218. tooltip: "true"
  219. },
  220. {
  221. title: "分管采购员",
  222. key: "purchaserName",
  223. tooltip: "true"
  224. },
  225. {
  226. title: "申请时间",
  227. key: "applicantTime",
  228. tooltip: "true"
  229. },
  230. {
  231. title: "所属区域",
  232. key: "areaName",
  233. tooltip: "true"
  234. },
  235. {
  236. title: "关联项目",
  237. key: "projectName",
  238. tooltip: "true"
  239. },
  240. {
  241. title: "审批状态",
  242. slot: "approvalState",
  243. tooltip: "true"
  244. },
  245. {
  246. title: "状态",
  247. slot: "orderState",
  248. tooltip: "true"
  249. },
  250. {
  251. title: "操作",
  252. slot: "action",
  253. width: 180
  254. }
  255. ],
  256. tableData: []
  257. };
  258. },
  259. created() {
  260. this.getTableData();
  261. getAreaList(localStorage.user_id).then(res => {
  262. this.ssqyList = res.items;
  263. });
  264. selectGoodProviderSelectionList().then(res => {
  265. this.gysList = res.data;
  266. });
  267. },
  268. methods: {
  269. resizePage() {
  270. this.resizeHeight = window.innerHeight - 282;
  271. this.resizeWidth = window.innerWidth;
  272. // this.handleWidth = this.$refs.handleHolder.offsetWidth;
  273. },
  274. ssqyChange(val) {
  275. let postData = {
  276. areaId: this.searchForm.ssqy,
  277. userId: localStorage.user_id
  278. };
  279. getProjectList(postData).then(res => {
  280. this.searchForm.glxm = "";
  281. this.glxmList = res.items;
  282. });
  283. },
  284. glxmChange(val) {},
  285. pageChange(val) {
  286. this.pageNum = val;
  287. },
  288. exportData() {
  289. let postData = {
  290. areaIds: `${this.searchForm.ssqy}`,
  291. projectIds: `${this.searchForm.glxm}`,
  292. purchaserId: this.searchForm.cgr,
  293. startTime: this.searchForm.xdsj[0],
  294. endTime: this.searchForm.xdsj[1],
  295. receivedName: this.searchForm.shr,
  296. gpId: this.searchForm.gys,
  297. approvalState: this.searchForm.spzt,
  298. orderState: this.searchForm.ddzt,
  299. queryText: this.searchForm.title
  300. };
  301. exportPurchaseOrder(postData);
  302. },
  303. //列表方法
  304. getTableData() {
  305. let postData = {
  306. page: this.pageNum,
  307. pageSize: 10,
  308. areaIds: `${this.searchForm.ssqy}`,
  309. projectIds: `${this.searchForm.glxm}`,
  310. purchaserId: this.searchForm.cgr,
  311. startTime: this.searchForm.xdsj[0],
  312. endTime: this.searchForm.xdsj[1],
  313. receivedName: this.searchForm.shr,
  314. gpId: this.searchForm.gys,
  315. approvalState: this.searchForm.spzt,
  316. orderState: this.searchForm.ddzt,
  317. queryText: this.searchForm.title
  318. };
  319. this.tableLoading = true;
  320. getPurchaseOrder(postData).then(res => {
  321. this.tableLoading = false;
  322. if (res.status == 200) {
  323. this.tableData = res.data.records;
  324. this.pageTotal = res.data.total;
  325. } else {
  326. this.$Message.error("获取采购订单列表失败。");
  327. }
  328. });
  329. },
  330. editRow(row) {
  331. this.addShow = true;
  332. this.$refs.add.getCgddXq(row.orderId);
  333. },
  334. submitRow(id) {
  335. this.$Modal.confirm({
  336. title: "提交",
  337. content: "是否确定提交该采购订单?",
  338. okText: "确定",
  339. onOk: () => {
  340. let postData = {
  341. orderId: id
  342. };
  343. submitPurchaseOrder(postData).then(res => {
  344. if (res.status == 200) {
  345. this.$Message.success("提交成功!");
  346. this.getTableData();
  347. } else {
  348. this.$Message.error(res.message);
  349. }
  350. });
  351. }
  352. });
  353. },
  354. cgddxd(id) {
  355. this.$Modal.confirm({
  356. title: "下单",
  357. content: "是否确定下单?",
  358. okText: "确定",
  359. onOk: () => {
  360. let str = `?orderId=${id}&state=3`;
  361. editPurchaseOrderState(str).then(res => {
  362. if ((res.status = 200)) {
  363. this.$Message.success("下单成功!");
  364. this.getTableData();
  365. }
  366. });
  367. }
  368. });
  369. },
  370. cgddqx(id) {
  371. this.$Modal.confirm({
  372. title: "取消订单",
  373. content: "是否确定取消该订单?",
  374. okText: "确定",
  375. onOk: () => {
  376. let str = `?orderId=${id}&state=6`;
  377. editPurchaseOrderState(str).then(res => {
  378. if ((res.status = 200)) {
  379. this.$Message.success("取消订单成功!");
  380. this.getTableData();
  381. }
  382. });
  383. }
  384. });
  385. },
  386. deleteRow(row) {
  387. this.$Modal.confirm({
  388. title: "删除",
  389. content: "是否确定删除该采购订单?",
  390. okText: "确定",
  391. onOk: () => {
  392. deletePurchaseOrder(row.orderId).then(res => {
  393. if ((res.status = 200)) {
  394. this.$Message.success("删除成功!");
  395. this.getTableData();
  396. }
  397. });
  398. }
  399. });
  400. },
  401. printRow(row) {
  402. this.printShow = true;
  403. this.$refs.print.getData(row.orderId);
  404. },
  405. tableOnSelect(selection, row) {}
  406. },
  407. mounted: function() {
  408. // 监听浏览器页面尺寸
  409. window.addEventListener("resize", this.resizePage);
  410. this.resizePage();
  411. }
  412. };
  413. </script>
  414. <style lang="scss" scoped>
  415. ivu-card-head-inner,
  416. .ivu-card-head p {
  417. display: inline-block;
  418. width: 100%;
  419. height: 20px;
  420. line-height: 20px;
  421. font-size: 14px;
  422. color: #17233d;
  423. font-weight: 700;
  424. overflow: hidden;
  425. text-overflow: ellipsis;
  426. white-space: nowrap;
  427. font-weight: normal;
  428. }
  429. </style>