purchasePlan.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. <template>
  2. <div>
  3. <Card style="width:100%" :bordered="false" :dis-hover="true" v-show="!printShow && !addShow">
  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. <Select clearable v-model="searchForm.jhlx" placeholder="计划类型">
  31. <Option v-for="item in jhlxList" :value="item.value" :key="item.value">{{ item.label }}</Option>
  32. </Select>
  33. </Col>
  34. <Col span="4">
  35. <DatePicker
  36. format="yyyy年MM月"
  37. :value="searchForm.jhyf"
  38. @on-change="searchForm.jhyf=$event"
  39. type="month"
  40. placeholder="计划月份"
  41. ></DatePicker>
  42. </Col>
  43. <Col span="4">
  44. <DatePicker
  45. :value="searchForm.zdrq"
  46. @on-change="searchForm.zdrq=$event"
  47. format="yyyy/MM/dd HH:mm"
  48. type="datetimerange"
  49. placeholder="制单日期"
  50. ></DatePicker>
  51. </Col>
  52. <Col span="4">
  53. <Select clearable filterable v-model="searchForm.fgcgy" placeholder="分管采购员">
  54. <Option
  55. v-for="item in fgcgyList"
  56. :value="item.userId"
  57. :key="item.userId"
  58. >{{ item.userName }}</Option>
  59. </Select>
  60. </Col>
  61. </Row>
  62. <Row :gutter="10" style="margin-bottom: 10px">
  63. <Col span="4">
  64. <Select clearable v-model="searchForm.spzt" placeholder="审批状态">
  65. <Option v-for="item in spztList" :value="item.value" :key="item.value">{{ item.label }}</Option>
  66. </Select>
  67. </Col>
  68. <Col span="4">
  69. <Input v-model="searchForm.title" placeholder="申请人/物料名称/计划单据号/标题" />
  70. </Col>
  71. <Col span="4">
  72. <Button type="primary" style="width: 80px" @click="getTableData">查询</Button>
  73. </Col>
  74. </Row>
  75. <!-- <Row style="margin-bottom: 10px; text-align: right">
  76. <Button type="primary" style="width: 80px" @click="getTableData">查询</Button>
  77. </Row>-->
  78. <Table
  79. :columns="tableColumn"
  80. style="width: 100%"
  81. :data="tableData"
  82. :height="resizeHeight - 65"
  83. :loading="tableLoading"
  84. @on-select="tableOnSelect"
  85. @on-row-dblclick="goDetail"
  86. >
  87. <template slot-scope="{ row, index }" slot="status">
  88. <div>
  89. <span v-if="row.status == '0'">未申购</span>
  90. <span v-if="row.status == '1'">待采购</span>
  91. <span v-if="row.status == '2'">采购中</span>
  92. <span v-if="row.status == '3'">已取消</span>
  93. <span v-if="row.status == '4'">已采购</span>
  94. <span v-if="row.status == '5'">审核不通过</span>
  95. </div>
  96. </template>
  97. <template slot-scope="{ row, index }" slot="applyStatus">
  98. <div>
  99. <span v-if="row.applyStatus == '0'">未发起</span>
  100. <span v-if="row.applyStatus == '1'">审批中</span>
  101. <span v-if="row.applyStatus == '2'">审批通过</span>
  102. <span v-if="row.applyStatus == '3'">审批不通过</span>
  103. <!-- <span v-if="row.applyStatus == '4'">审批驳回</span> -->
  104. </div>
  105. </template>
  106. <template slot-scope="{ row, index }" slot="type">
  107. <div>
  108. <span v-if="row.type == '1'">计划性申购</span>
  109. <span v-if="row.type == '2'">临时申购</span>
  110. </div>
  111. </template>
  112. <template slot-scope="{ row, index }" slot="action">
  113. <div>
  114. <a href="javascript:;" @click="editRow(row)">编辑</a>
  115. <!-- <a href="javascript:;">复制</a> -->
  116. <a href="javascript:;" v-if="row.applyStatus == '0'" @click="deleteRow(row)">删除</a>
  117. <a
  118. href="javascript:;"
  119. v-if="row.applyStatus == '2' || row.applyStatus == '3'"
  120. @click="copyRow(row)"
  121. >复制</a>
  122. <a href="javascript:;" @click="printRow(row)">打印</a>
  123. <a
  124. href="javascript:;"
  125. v-if="row.applyStatus == '0' || row.applyStatus == '3'"
  126. @click="submitRow(row)"
  127. >提交</a>
  128. </div>
  129. </template>
  130. </Table>
  131. <Page align="right" :total="pageTotal" @on-change="pageChange" show-total />
  132. </Card>
  133. <planAdd
  134. ref="add"
  135. @return="() => {addShow = false; getTableData()}"
  136. :ssqyList="ssqyList"
  137. :cgyList="fgcgyList"
  138. v-show="addShow"
  139. />
  140. <planPrint ref="print" @return="() => {printShow = false ; getTableData()}" v-show="printShow" />
  141. </div>
  142. </template>
  143. <script>
  144. import {
  145. queryPurchaseApplyList,
  146. getAreaList,
  147. getProjectList,
  148. deletePurchaseApply,
  149. getJobList,
  150. exportPurchaseInfo,
  151. submitPurchaseApply,
  152. queryPurchaseApplyInfo,
  153. addPurchaseApply
  154. } from "@/service/getData";
  155. import planAdd from "./components/plan/planAdd";
  156. import PlanPrint from "./components/plan/planPrint";
  157. export default {
  158. components: {
  159. planAdd,
  160. PlanPrint
  161. },
  162. data() {
  163. return {
  164. addShow: false,
  165. printShow: false,
  166. // 自适应尺寸↓
  167. resizeHeight: 100,
  168. resizeWidth: 100,
  169. handleWidth: 100,
  170. // 顶部搜索
  171. searchForm: {
  172. ssqy: "", //所属区域
  173. glxm: "", //关联项目
  174. jhlx: "", //计划类型
  175. jhyf: "", //计划月份
  176. zdrq: [], //制单日期
  177. fgcgy: "", //分管采购员
  178. spzt: "", //审批状态
  179. title: "" //申请人/物料名称/计划单据号/标题
  180. },
  181. ssqyList: [],
  182. glxmList: [],
  183. jhlxList: [
  184. { label: "计划性申购", value: 1 },
  185. { label: "临时申购", value: 2 }
  186. ],
  187. fgcgyList: [],
  188. spztList: [
  189. { label: "未发起", value: 0 },
  190. { label: "审批中", value: 1 },
  191. { label: "审批通过", value: 2 },
  192. { label: "审批不通过", value: 3 }
  193. // { label: "审批驳回", value: 4 }
  194. ],
  195. // 表格参数
  196. tableLoading: false,
  197. pageTotal: 0,
  198. pageNum: 1,
  199. tableColumn: [
  200. // {
  201. // type: "selection",
  202. // width: 60,
  203. // align: "center"
  204. // },
  205. {
  206. title: "操作",
  207. slot: "action",
  208. width: 180
  209. },
  210. {
  211. title: "计划单据号",
  212. key: "code",
  213. tooltip: "true",
  214. width: 100
  215. },
  216. {
  217. title: "标题",
  218. key: "title",
  219. tooltip: "true",
  220. width: 100
  221. },
  222. {
  223. title: "状态",
  224. slot: "status",
  225. tooltip: "true",
  226. width: 100
  227. },
  228. {
  229. title: "审批状态",
  230. slot: "applyStatus",
  231. tooltip: "true",
  232. width: 100
  233. },
  234. {
  235. title: "计划类型",
  236. slot: "type",
  237. tooltip: "true",
  238. width: 100
  239. },
  240. {
  241. title: "计划月份",
  242. key: "applyMonth",
  243. tooltip: "true",
  244. width: 100
  245. },
  246. {
  247. title: "计划到货时间",
  248. key: "arriveTime",
  249. tooltip: "true",
  250. width: 100
  251. },
  252. {
  253. title: "总价(元)",
  254. key: "referencePrice",
  255. tooltip: "true",
  256. width: 100
  257. },
  258. {
  259. title: "申请人",
  260. key: "applicantName",
  261. tooltip: "true",
  262. width: 100
  263. },
  264. {
  265. title: "分管采购员",
  266. key: "purchaserName",
  267. tooltip: "true",
  268. width: 100
  269. },
  270. {
  271. title: "所属区域",
  272. key: "areaName",
  273. tooltip: "true",
  274. width: 100
  275. },
  276. {
  277. title: "关联项目",
  278. key: "projectName",
  279. tooltip: "true",
  280. width: 100
  281. },
  282. {
  283. title: "创建时间",
  284. key: "createTime",
  285. tooltip: "true",
  286. width: 100
  287. },
  288. {
  289. title: "提交时间",
  290. key: "submitTime",
  291. tooltip: "true",
  292. width: 100
  293. },
  294. {
  295. title: "审批通过时间",
  296. key: "applyTime",
  297. tooltip: "true",
  298. width: 100
  299. }
  300. ],
  301. tableData: [],
  302. tableSelect: []
  303. };
  304. },
  305. created() {
  306. this.getTableData();
  307. getAreaList(localStorage.user_id).then(res => {
  308. this.ssqyList = res.items;
  309. });
  310. getJobList().then(res => {
  311. if (res.status == 200) {
  312. this.fgcgyList = res.data;
  313. } else {
  314. this.$Message.error("获取分管采购员列表失败!");
  315. }
  316. });
  317. },
  318. methods: {
  319. goDetail(row, index) {
  320. if (row.applyStatus != "3") {
  321. this.editRow(row);
  322. } else {
  323. window.open(
  324. `https://test.hajwy.com/purchase-web/#/viewPurchaseApply?id=${row.id}`
  325. );
  326. }
  327. // window.open(`/#/viewPurchaseApply?id=${row.id}`);
  328. },
  329. resizePage() {
  330. this.resizeHeight = window.innerHeight - 282;
  331. this.resizeWidth = window.innerWidth;
  332. // this.handleWidth = this.$refs.handleHolder.offsetWidth;
  333. },
  334. ssqyChange(val) {
  335. let postData = {
  336. areaId: this.searchForm.ssqy,
  337. userId: localStorage.user_id
  338. };
  339. getProjectList(postData).then(res => {
  340. this.searchForm.glxm = "";
  341. this.glxmList = res.items;
  342. });
  343. },
  344. glxmChange(val) {},
  345. //申购计划导出
  346. exportData() {
  347. let postData = {
  348. type: this.searchForm.jhlx,
  349. applyMonth: this.searchForm.jhyf,
  350. purchaserId: this.searchForm.fgcgy,
  351. applyStatus: this.searchForm.spzt,
  352. page: this.pageNum,
  353. pageSize: 10,
  354. queryText: this.searchForm.title,
  355. // createStartTime: this.searchForm.zdrq[0],
  356. // createEndTime: this.searchForm.zdrq[1],
  357. areaIds: this.searchForm.ssqy,
  358. projectIds: this.searchForm.glxm
  359. };
  360. if (this.searchForm.zdrq.length > 0) {
  361. postData.createStartTime = this.searchForm.zdrq[0];
  362. postData.createEndTime = this.searchForm.zdrq[1];
  363. }
  364. console.log(postData, 11111111111111111);
  365. exportPurchaseInfo(postData);
  366. },
  367. //打印
  368. printRow(row) {
  369. this.printShow = true;
  370. this.$refs.print.getPrintData(row.id);
  371. },
  372. //列表页方法
  373. getTableData() {
  374. let postData = {
  375. type: this.searchForm.jhlx,
  376. applyMonth: this.searchForm.jhyf,
  377. purchaserId: this.searchForm.fgcgy,
  378. applyStatus: this.searchForm.spzt,
  379. page: this.pageNum,
  380. pageSize: 10,
  381. queryText: this.searchForm.title,
  382. areaIds: this.searchForm.ssqy,
  383. projectIds: this.searchForm.glxm
  384. };
  385. if (this.searchForm.zdrq.length > 0) {
  386. postData.createStartTime = this.searchForm.zdrq[0];
  387. postData.createEndTime = this.searchForm.zdrq[1];
  388. }
  389. this.tableLoading = true;
  390. queryPurchaseApplyList(postData).then(res => {
  391. this.tableLoading = false;
  392. if (res.status == 200) {
  393. this.tableData = res.data.records;
  394. for (let i in this.tableData) {
  395. if (this.tableData[i].arriveTime) {
  396. this.tableData[i].arriveTime = this.tableData[i].arriveTime.split(
  397. " "
  398. )[0];
  399. }
  400. }
  401. this.pageTotal = res.data.total;
  402. } else {
  403. this.$Message.error(res.message);
  404. }
  405. });
  406. },
  407. //行编辑
  408. editRow(row) {
  409. if (row.applyStatus != "3") {
  410. this.addShow = true;
  411. this.$refs.add.planType = "edit";
  412. this.$refs.add.getSgjh(row.id);
  413. } else {
  414. window.open(
  415. `https://test.hajwy.com/purchase-web/#/viewPurchaseApply?id=${row.id}`
  416. );
  417. }
  418. },
  419. //行删除
  420. deleteRow(row) {
  421. this.$Modal.confirm({
  422. title: "删除",
  423. content: "是否确定删除该申购计划?",
  424. okText: "确定",
  425. onOk: () => {
  426. let postData = {
  427. id: row.id
  428. };
  429. deletePurchaseApply(postData).then(res => {
  430. if (res.status == 200) {
  431. this.$Message.success("删除成功!");
  432. this.getTableData();
  433. } else {
  434. this.$Message.error(res.message);
  435. }
  436. });
  437. }
  438. });
  439. },
  440. //行复制
  441. copyRow(row) {
  442. let postData = {
  443. id: row.id
  444. };
  445. queryPurchaseApplyInfo(postData).then(res => {
  446. if (res.status == 200) {
  447. let data = res.data;
  448. let postData = {
  449. areaId: data.areaId,
  450. areaName: data.areaName,
  451. projectId: data.projectId,
  452. projectName: data.projectName,
  453. type: data.type,
  454. applyMonth: `${new Date().getFullYear()}年${new Date().getMonth() +
  455. 1}月`,
  456. purchaserId: data.purchaserId,
  457. purchaserName: data.purchaserName,
  458. applicantId: localStorage.user_id,
  459. applicantName: localStorage.user_name,
  460. attachmentList: data.filesList,
  461. remark: data.remark
  462. };
  463. let arr = [];
  464. for (let i in data.detailList) {
  465. data.detailList[i].arriveTime = "";
  466. }
  467. arr = data.detailList;
  468. addPurchaseApply(postData).then(res => {
  469. if (res.status == 200) {
  470. this.$Message.success("复制申购计划成功!");
  471. this.addShow = true;
  472. this.$refs.add.planType = "edit";
  473. this.$refs.add.getSgjh(res.data.id, arr);
  474. }
  475. });
  476. } else {
  477. this.$Message.error(res.message);
  478. }
  479. });
  480. },
  481. //行提交
  482. submitRow(row) {
  483. this.$Modal.confirm({
  484. title: "提交",
  485. content: "是否确定提交该申购计划?",
  486. okText: "确定",
  487. onOk: () => {
  488. let postData = {
  489. id: row.id
  490. };
  491. submitPurchaseApply(postData).then(res => {
  492. if (res.status == 200) {
  493. this.$Message.success("提交成功!");
  494. this.getTableData();
  495. } else {
  496. this.$Message.error(res.message);
  497. }
  498. });
  499. }
  500. });
  501. },
  502. pageChange(val) {
  503. this.pageNum = val;
  504. this.getTableData();
  505. },
  506. tableOnSelect(selection, row) {}
  507. },
  508. mounted: function() {
  509. // 监听浏览器页面尺寸
  510. window.addEventListener("resize", this.resizePage);
  511. this.resizePage();
  512. }
  513. };
  514. </script>
  515. <style lang="scss" scoped>
  516. ivu-card-head-inner,
  517. .ivu-card-head p {
  518. display: inline-block;
  519. width: 100%;
  520. height: 20px;
  521. line-height: 20px;
  522. font-size: 14px;
  523. color: #17233d;
  524. font-weight: 700;
  525. overflow: hidden;
  526. text-overflow: ellipsis;
  527. white-space: nowrap;
  528. font-weight: normal;
  529. }
  530. </style>