planAdd.vue 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144
  1. <template>
  2. <div>
  3. <!-- 页面主体内容 -->
  4. <div class="planAddContent">
  5. <Card style="width:100%" :bordered="false" :dis-hover="true">
  6. <p slot="title">申购计划详情</p>
  7. <div slot="extra">
  8. <Button v-if="form.spzt != '0'" @click="toSpjl">查看审批记录</Button>
  9. <Button
  10. @click="addSgjh"
  11. v-if="form.spzt == '0' && (form.status = '1' || form.status == '2')"
  12. >保存</Button>
  13. <Button
  14. @click="submitSgjh"
  15. v-if="planType == 'edit' && (form.spzt == '0' || form.spzt == '3')"
  16. >提交</Button>
  17. <Button @click="cancel">返回</Button>
  18. </div>
  19. <Row class="mainCont">
  20. <Col span="4" class-name="tables">计划单据号</Col>
  21. <Col span="4" class-name="tables">
  22. <span style="color: gray" v-if="form.jhdjh == ''">系统自动生成,不可编辑</span>
  23. <span v-else>{{ form.jhdjh }}</span>
  24. </Col>
  25. <Col span="4" class-name="tables">
  26. 所属区域
  27. <span class="mustSpan">*</span>
  28. </Col>
  29. <Col span="4" class-name="tables">
  30. <Select
  31. clearable
  32. v-model="form.ssqy"
  33. style="width: 95%"
  34. @on-change="ssqyChange"
  35. :disabled="planType == 'edit'"
  36. >
  37. <Option
  38. v-for="item in ssqyList"
  39. :value="item.areaId + ',' + item.areaName"
  40. :key="item.areaId"
  41. >{{ item.areaName }}</Option>
  42. </Select>
  43. </Col>
  44. <Col span="4" class-name="tables">
  45. 所属项目
  46. <span class="mustSpan">*</span>
  47. </Col>
  48. <Col span="4" class-name="tables">
  49. <Select clearable v-model="form.ssxm" style="width: 95%" :disabled="planType == 'edit'">
  50. <Option
  51. v-for="item in ssxmList"
  52. :value="item.projectId + ',' + item.projectName"
  53. :key="item.projectId"
  54. >{{ item.projectName }}</Option>
  55. </Select>
  56. </Col>
  57. <Col span="4" class-name="tables">标题</Col>
  58. <Col span="4" class-name="tables">
  59. <span style="color: gray" v-if="form.bt == ''">系统自动生成,不可编辑</span>
  60. <span v-else>{{ form.bt }}</span>
  61. </Col>
  62. <Col span="4" class-name="tables">参考总价(元)</Col>
  63. <Col span="4" class-name="tables">{{ form.totalPrice }}</Col>
  64. <Col span="4" class-name="tables">
  65. 计划类型
  66. <span class="mustSpan">*</span>
  67. </Col>
  68. <Col span="4" class-name="tables">
  69. <Select
  70. v-model="form.jhlx"
  71. :disabled="form.spzt == '2' || form.spzt == '1'"
  72. style="width: 95%"
  73. >
  74. <Option
  75. v-for="item in jhlxList"
  76. :value="item.value"
  77. :key="item.value"
  78. >{{ item.label }}</Option>
  79. </Select>
  80. </Col>
  81. <Col span="4" class-name="tables">
  82. 计划月份
  83. <span class="mustSpan">*</span>
  84. </Col>
  85. <Col span="4" class-name="tables">
  86. <DatePicker
  87. :disabled="planType == 'edit'"
  88. style="width: 95%"
  89. format="yyyy年MM月"
  90. :value="form.date"
  91. @on-change="form.date=$event"
  92. :options="jhyfOption"
  93. type="month"
  94. placeholder="请选择"
  95. ></DatePicker>
  96. </Col>
  97. <Col span="4" class-name="tables">
  98. 分管采购员
  99. <span class="mustSpan">*</span>
  100. </Col>
  101. <Col span="4" class-name="tables">
  102. <Select
  103. v-model="form.fgcgy"
  104. filterable
  105. :disabled="form.spzt == '2' || form.spzt == '1'"
  106. style="width: 95%"
  107. >
  108. <Option
  109. v-for="item in cgyList"
  110. :value="item.userId"
  111. :key="item.userId"
  112. >{{ item.userName }}</Option>
  113. </Select>
  114. </Col>
  115. <Col span="4" class-name="tables">申请人</Col>
  116. <Col span="4" class-name="tables">
  117. <span>{{ form.sqr }}</span>
  118. </Col>
  119. <Col span="4" class-name="tables">审批状态</Col>
  120. <Col span="4" class-name="tables">
  121. <span v-if="form.spzt == '0'">未发起</span>
  122. <span v-if="form.spzt == '1'">审批中</span>
  123. <span v-if="form.spzt == '2'">审批通过</span>
  124. <span v-if="form.spzt == '3'">审批不通过</span>
  125. <span v-if="form.spzt == '4'">审批驳回</span>
  126. </Col>
  127. <Col span="4" class-name="tables"></Col>
  128. <Col span="4" class-name="tables"></Col>
  129. <Col span="4" class-name="tables"></Col>
  130. <Col span="4" class-name="tables"></Col>
  131. </Row>
  132. <Row class="uplCont" type="flex" justify="center" style="align-items: stretch">
  133. <Col span="4" class-name="upl">附件</Col>
  134. <Col span="10" class-name="uplf">
  135. <Upload
  136. :headers="uploadHeaders"
  137. style="width: 80%"
  138. multiple
  139. type="drag"
  140. action="/purchase/common/uploadFile"
  141. :before-upload="beforeUpload"
  142. :on-success="uploadFilesSuccess"
  143. :show-upload-list="false"
  144. :disabled="form.spzt == '2' || form.spzt == '1'"
  145. :on-progress="upFilesLoading"
  146. >
  147. <!-- :default-file-list="xzwgForm.filesList" -->
  148. <div style="padding: 5px 0">
  149. <Icon type="md-cloud-upload" size="36" style="color: #3399ff"></Icon>
  150. <span>点击或将文件拖拽到这里上传</span>
  151. </div>
  152. </Upload>
  153. </Col>
  154. <Col span="10" class="upl" style="padding: 5px">
  155. <div v-for="(item, index) in form.filesList" :key="index">
  156. <a
  157. :href="item.docUrl ? item.docUrl : 'javascript:void(0);'"
  158. :download="item.fileName"
  159. :target="item.docUrl ? '_blank' : '_self'"
  160. >{{ item.fileName }}</a>
  161. <span
  162. v-if="form.spzt == '0' || form.spzt == '3' || form.spzt == '4'"
  163. style="float: right; cursor:pointer"
  164. @click="form.filesList.splice(index, 1)"
  165. >x</span>
  166. </div>
  167. <p v-if="uploading" style="text-align: center">上传中...</p>
  168. </Col>
  169. </Row>
  170. <Row class="mainCont">
  171. <Col span="4" class-name="tables">说明</Col>
  172. <Col span="20" class-name="tables">
  173. <Input
  174. v-model="form.sm"
  175. :disabled="form.spzt == '2' || form.spzt == '1'"
  176. placeholder="请输入"
  177. style="width: 99%"
  178. />
  179. </Col>
  180. </Row>
  181. <Spin size="large" fix v-if="spinShow"></Spin>
  182. </Card>
  183. <Card style="width:100%" :bordered="false" :dis-hover="true">
  184. <p slot="title">申购计划明细</p>
  185. <div slot="extra">
  186. <Button
  187. v-show="tableData.length"
  188. type="primary"
  189. @click="plszOpen"
  190. :disabled="form.spzt == '2' || form.spzt == '1'"
  191. >批量设置</Button>
  192. <!-- <Button type="primary">批量导入</Button> -->
  193. <Button
  194. type="primary"
  195. @click="addMxShow"
  196. :disabled="planType == 'add' || form.spzt == '2' || form.spzt == '1'"
  197. >新增明细</Button>
  198. </div>
  199. <Table
  200. :columns="tableColumn"
  201. style="width: 100%"
  202. :data="tableData"
  203. :loading="tableLoading"
  204. @on-select="tableOnSelect"
  205. @on-select-cancel="tableOnCancel"
  206. @on-select-all="tableOnSelect"
  207. @on-select-all-cancel="tableOnCancel"
  208. >
  209. <template slot-scope="{ row, index }" slot="amount">
  210. <div>
  211. <InputNumber
  212. :min="1"
  213. :precision="2"
  214. v-model="tableData[index].amount"
  215. :disabled="form.spzt == '2' || form.spzt == '1'"
  216. placeholder="请输入"
  217. style="width: 95%"
  218. />
  219. </div>
  220. </template>
  221. <template slot-scope="{ row, index }" slot="storehouseId">
  222. <Select
  223. :disabled="form.spzt == '2' || form.spzt == '1'"
  224. v-model="tableData[index].storehouseId"
  225. style="width: 95%"
  226. :transfer="true"
  227. >
  228. <Option v-for="item in ckList" :value="item.twId" :key="item.twId">{{ item.twName }}</Option>
  229. </Select>
  230. </template>
  231. <template slot-scope="{ row, index }" slot="linkedPersonName">
  232. <span>{{ row.linkedPersonName }}</span>
  233. </template>
  234. <!-- <template slot-scope="{ row, index }" slot="billType">
  235. <Select
  236. :disabled="form.spzt == '2' || form.spzt == '1'"
  237. v-model="tableData[index].billType"
  238. style="width: 95%"
  239. :transfer="true"
  240. >
  241. <Option v-for="item in djList" :value="item.value" :key="item.value">{{ item.label }}</Option>
  242. </Select>
  243. </template>-->
  244. <template slot-scope="{ row, index }" slot="referenceTotalPrice">
  245. <span>{{ (row.amount * row.referencePrice).toFixed(2) }}</span>
  246. </template>
  247. <template slot-scope="{ row, index }" slot="arriveTime">
  248. <DatePicker
  249. :disabled="form.spzt == '2' || form.spzt == '1'"
  250. :transfer="true"
  251. format="yyyy-MM-dd"
  252. :options="jhdhsjOption"
  253. type="date"
  254. :value="tableData[index].arriveTime"
  255. @on-change="tableData[index].arriveTime=$event"
  256. placeholder="请选择"
  257. style="width: 95%"
  258. ></DatePicker>
  259. </template>
  260. <!-- @on-change="((val, date) => tableDateChange(val, date ,index))" -->
  261. <template slot-scope="{ row, index }" slot="remark">
  262. <Input
  263. :disabled="form.spzt == '2' || form.spzt == '1'"
  264. v-model="tableData[index].remark"
  265. placeholder="请输入"
  266. style="width: 95%"
  267. />
  268. </template>
  269. <template
  270. slot-scope="{ row, index }"
  271. slot="isCancel"
  272. >{{ row.isCancel == '0' ? '有效' : '已取消' }}</template>
  273. <template slot-scope="{ row, index }" slot="cz">
  274. <div
  275. v-if="form.spzt != '1' && form.spzt !='2' && (form.status = '1' || form.status == '2')"
  276. >
  277. <a href="javascript:;" @click="deleteRow(index)">删除</a>
  278. </div>
  279. <div v-if="row.isCancel == '0' && form.spzt == '2'">
  280. <a href="javascript:;" @click="cancelRow(row, index)">取消</a>
  281. </div>
  282. </template>
  283. </Table>
  284. </Card>
  285. <Modal v-model="plszShow" title="批量设置" @on-ok="plszOk" @on-cancel="plszCancel">
  286. <Row class="mainCont">
  287. <Col span="12" class-name="tables">入库仓库</Col>
  288. <Col span="12" class-name="tables">
  289. <Select
  290. :disabled="form.spzt == '2' || form.spzt == '1'"
  291. clearable
  292. v-model="plrkck"
  293. style="width: 95%"
  294. :transfer="true"
  295. >
  296. <Option v-for="item in ckList" :value="item.twId" :key="item.twId">{{ item.twName }}</Option>
  297. </Select>
  298. </Col>
  299. <Col span="12" class-name="tables">计划到货时间</Col>
  300. <Col span="12" class-name="tables">
  301. <DatePicker
  302. :disabled="form.spzt == '2' || form.spzt == '1'"
  303. :transfer="true"
  304. format="yyyy-MM-dd"
  305. type="date"
  306. :value="pldhsj"
  307. @on-change="pldhsj=$event"
  308. :options="jhdhsjOption"
  309. placeholder="请选择"
  310. style="width: 95%"
  311. ></DatePicker>
  312. </Col>
  313. </Row>
  314. </Modal>
  315. </div>
  316. <!-- 计划明细新增 -->
  317. <Modal v-model="contentShow" title="新增申购计划物料" width="1200px">
  318. <planMxAdd ref="add" @plAdd="plAdd" />
  319. <div slot="footer">
  320. <!-- <Button :loading="buttonLoading" @click="addCancel">取消</Button>
  321. <Button type="primary" :loading="buttonLoading" @click="addOk">确认</Button>-->
  322. </div>
  323. </Modal>
  324. </div>
  325. </template>
  326. <script>
  327. import {
  328. getProjectList,
  329. addPurchaseApply,
  330. queryPurchaseApplyInfo,
  331. editPurchaseApply,
  332. warehouseList,
  333. submitPurchaseApply,
  334. getLabelByCode4Purchase,
  335. editPurchaseApplyDetailState
  336. } from "@/service/getData";
  337. import planMxAdd from "./planMxAdd";
  338. export default {
  339. name: "planAdd",
  340. components: {
  341. planMxAdd
  342. },
  343. props: ["ssqyList", "cgyList"],
  344. data() {
  345. return {
  346. planMxAddvisible: false,
  347. id: "",
  348. spinShow: false,
  349. contentShow: false,
  350. requestId: "",
  351. planType: "add",
  352. uploadHeaders: {
  353. token: localStorage.token,
  354. userId: localStorage.user_id
  355. },
  356. jhyfOption: {
  357. disabledDate(date) {
  358. let nDate = new Date();
  359. let dn = +new Date(`${nDate.getFullYear()}-${nDate.getMonth() + 1}`);
  360. return date.valueOf() < dn;
  361. }
  362. },
  363. jhdhsjOption: {
  364. disabledDate(date) {
  365. let nDate = new Date();
  366. let dn = +new Date(
  367. `${nDate.getFullYear()}-${nDate.getMonth() + 1}-${nDate.getDate()}`
  368. );
  369. return date.valueOf() < dn;
  370. }
  371. },
  372. form: {
  373. status: "", //申购计划状态
  374. jhdjh: "", // 计划单据号
  375. bt: "", //标题
  376. spzt: 0, //审批状态
  377. date: "", //计划月份
  378. ssqy: "", //所属区域
  379. ssxm: "", //所属项目
  380. jhlx: "", //计划类型
  381. fgcgy: "", //分管采购员
  382. totalPrice: 0, //总价
  383. sqr: localStorage.user_name, //申请人
  384. filesList: []
  385. },
  386. // ssqyList: [{ label: "test", value: "1" }],
  387. ssxmList: [],
  388. jhlxList: [
  389. { label: "计划性申购", value: 1 },
  390. { label: "临时申购", value: 2 }
  391. ],
  392. sqrList: [],
  393. uploading: false,
  394. // 批量设置
  395. plszShow: false,
  396. plrkck: "",
  397. pldhsj: "",
  398. // table
  399. ckList: [],
  400. djList: [],
  401. tableColumn: [
  402. {
  403. type: "selection",
  404. width: 60,
  405. align: "center"
  406. },
  407. {
  408. title: "物料编码",
  409. key: "code",
  410. tooltip: "true",
  411. width: 100
  412. },
  413. {
  414. title: "物料分类",
  415. key: "firstClassName",
  416. tooltip: "true",
  417. width: 100
  418. },
  419. {
  420. title: "物料名称",
  421. key: "materialName",
  422. tooltip: "true",
  423. width: 100
  424. },
  425. {
  426. title: "规格型号",
  427. key: "specs",
  428. tooltip: "true",
  429. width: 100
  430. },
  431. {
  432. title: "单位",
  433. key: "unit",
  434. tooltip: "true",
  435. width: 100
  436. },
  437. {
  438. title: "库存量",
  439. key: "inventory",
  440. tooltip: "true",
  441. width: 100
  442. },
  443. {
  444. title: "申购数量",
  445. slot: "amount",
  446. tooltip: "true",
  447. width: 100
  448. },
  449. {
  450. title: "参考单价(元)",
  451. key: "referencePrice",
  452. tooltip: "true",
  453. width: 120
  454. },
  455. {
  456. title: "参考总价(元)",
  457. slot: "referenceTotalPrice",
  458. tooltip: "true",
  459. width: 120
  460. },
  461. {
  462. title: "入库仓库",
  463. slot: "storehouseId",
  464. tooltip: "true",
  465. width: 100
  466. },
  467. {
  468. title: "对接人",
  469. slot: "linkedPersonName",
  470. tooltip: "true",
  471. width: 100
  472. },
  473. // {
  474. // title: "单据类型",
  475. // slot: "billType",
  476. // tooltip: "true",
  477. // width: 100
  478. // },
  479. {
  480. title: "计划到货时间",
  481. slot: "arriveTime",
  482. tooltip: "true",
  483. width: 130
  484. },
  485. {
  486. title: "备注",
  487. slot: "remark",
  488. tooltip: "true",
  489. width: 150
  490. },
  491. // {
  492. // title: "状态",
  493. // slot: "isCancel",
  494. // tooltip: "true",
  495. // width: 100
  496. // },
  497. {
  498. title: "操作",
  499. slot: "cz",
  500. tooltip: "true",
  501. width: 60
  502. }
  503. ],
  504. tableData: [],
  505. tableSelect: [],
  506. tableLoading: false
  507. };
  508. },
  509. created() {
  510. // getLabelByCode4Purchase({ dictCode: "billType" }).then(res => {
  511. // if (res.status == 200) {
  512. // this.djList = res.data;
  513. // } else {
  514. // this.$Message.error(res.message);
  515. // }
  516. // });
  517. },
  518. methods: {
  519. //批量设置弹窗
  520. plszOpen() {
  521. if (!this.tableSelect.length) {
  522. this.$Message.error("请至少选择一条物料明细!");
  523. return false;
  524. } else {
  525. this.plszShow = true;
  526. }
  527. },
  528. plszOk() {
  529. let ck = this.plrkck ? this.plrkck : "";
  530. let sj = this.pldhsj ? this.pldhsj : "";
  531. let select = this.tableSelect;
  532. for (let item in this.tableData) {
  533. let id = this.tableData[item].id;
  534. if (select.filter(a => a.id == id).length > 0) {
  535. if (ck != "") {
  536. this.tableData[item].storehouseId = ck;
  537. }
  538. if (sj != "") {
  539. this.tableData[item].arriveTime = sj;
  540. }
  541. }
  542. }
  543. },
  544. plszCancel() {},
  545. //表单上传
  546. beforeUpload() {},
  547. upFilesLoading() {
  548. this.uploading = true;
  549. },
  550. uploadFilesSuccess(response, file, fileList) {
  551. this.uploading = false;
  552. this.form.filesList.push({
  553. fileName: response.data.fileName,
  554. filePath: response.data.filePath,
  555. fileDetailType: ""
  556. });
  557. },
  558. plAdd(list) {
  559. this.contentShow = false;
  560. for (let item in list) {
  561. if (
  562. this.tableData.filter(a => a.materialId == list[item].materialId)
  563. .length > 0
  564. ) {
  565. } else {
  566. this.tableData.push(list[item]);
  567. }
  568. }
  569. },
  570. //查询申购计划详情
  571. getSgjh(id, arr) {
  572. this.id = id;
  573. let postData = {
  574. id: id
  575. };
  576. this.spinShow = true;
  577. queryPurchaseApplyInfo(postData).then(res => {
  578. this.spinShow = false;
  579. if (res.status == 200) {
  580. this.form.jhdjh = res.data.code;
  581. this.form.bt = res.data.title;
  582. this.form.ssqy = `${res.data.areaId},${res.data.areaName}`;
  583. this.form.ssxm = `${res.data.projectId},${res.data.projectName}`;
  584. this.form.jhlx = res.data.type;
  585. this.form.date = res.data.applyMonth;
  586. // this.form.fgcgy = res.data.purchaserName;
  587. this.form.sqr = res.data.applicantName;
  588. this.form.spzt = res.data.applyStatus;
  589. if (res.data.applyStatus == "2") {
  590. this.tableColumn = [
  591. {
  592. type: "selection",
  593. width: 60,
  594. align: "center"
  595. },
  596. {
  597. title: "物料编码",
  598. key: "code",
  599. tooltip: "true",
  600. width: 100
  601. },
  602. {
  603. title: "物料分类",
  604. key: "firstClassName",
  605. tooltip: "true",
  606. width: 100
  607. },
  608. {
  609. title: "物料名称",
  610. key: "materialName",
  611. tooltip: "true",
  612. width: 100
  613. },
  614. {
  615. title: "规格型号",
  616. key: "specs",
  617. tooltip: "true",
  618. width: 100
  619. },
  620. {
  621. title: "单位",
  622. key: "unit",
  623. tooltip: "true",
  624. width: 100
  625. },
  626. {
  627. title: "库存量",
  628. key: "inventory",
  629. tooltip: "true",
  630. width: 100
  631. },
  632. {
  633. title: "申购数量",
  634. slot: "amount",
  635. tooltip: "true",
  636. width: 100
  637. },
  638. {
  639. title: "参考单价(元)",
  640. key: "referencePrice",
  641. tooltip: "true",
  642. width: 120
  643. },
  644. {
  645. title: "参考总价(元)",
  646. slot: "referenceTotalPrice",
  647. tooltip: "true",
  648. width: 120
  649. },
  650. {
  651. title: "入库仓库",
  652. slot: "storehouseId",
  653. tooltip: "true",
  654. width: 100
  655. },
  656. {
  657. title: "对接人",
  658. slot: "linkedPersonName",
  659. tooltip: "true",
  660. width: 100
  661. },
  662. // {
  663. // title: "单据类型",
  664. // slot: "billType",
  665. // tooltip: "true",
  666. // width: 100
  667. // },
  668. {
  669. title: "计划到货时间",
  670. slot: "arriveTime",
  671. tooltip: "true",
  672. width: 130
  673. },
  674. {
  675. title: "备注",
  676. slot: "remark",
  677. tooltip: "true",
  678. width: 150
  679. },
  680. {
  681. title: "状态",
  682. slot: "isCancel",
  683. tooltip: "true",
  684. width: 100
  685. },
  686. {
  687. title: "操作",
  688. slot: "cz",
  689. tooltip: "true",
  690. width: 60
  691. }
  692. ];
  693. }
  694. this.form.status = res.data.status;
  695. this.form.fgcgy = `${res.data.purchaserId}`;
  696. this.form.ylh = res.data.gpUnionpayNo;
  697. this.form.sf = res.data.gpProvince;
  698. this.form.yb = res.data.gpPostalCode;
  699. this.form.email = res.data.gpEmail;
  700. this.form.fax = res.data.gpFax;
  701. this.form.filesList = res.data.attachmentList;
  702. this.form.sm = res.data.remark;
  703. this.requestId = res.data.requestId;
  704. let postData = {
  705. areaId: this.form.ssqy.split(",")[0],
  706. userId: localStorage.user_id
  707. };
  708. getProjectList(postData).then(res => {
  709. this.ssxmList = res.items;
  710. });
  711. let getData = {
  712. areaId: res.data.areaId,
  713. projectId: res.data.projectId
  714. };
  715. warehouseList(getData).then(res => {
  716. if (res.status == 200) {
  717. for (let i in res.data) {
  718. res.data[i].twId = res.data[i].twId;
  719. }
  720. this.ckList = res.data;
  721. }
  722. });
  723. if (arr) {
  724. this.tableData = arr;
  725. } else {
  726. this.tableData = res.data.detailList;
  727. }
  728. }
  729. });
  730. },
  731. //新增申购计划
  732. addSgjh() {
  733. let mustArr = ["ssqy", "ssxm", "jhlx", "date", "fgcgy"];
  734. for (let i in mustArr) {
  735. if (!this.form[mustArr[i]]) {
  736. this.$Message.error("请将信息填写完整!");
  737. return false;
  738. }
  739. if (this.form[mustArr[i]] == "" || this.form[mustArr[i]].length == 0) {
  740. this.$Message.error("请将信息填写完整!");
  741. return false;
  742. }
  743. }
  744. if (this.planType == "add") {
  745. let postData = {
  746. areaId: this.form.ssqy.split(",")[0],
  747. areaName: this.form.ssqy.split(",")[1],
  748. projectId: this.form.ssxm.split(",")[0],
  749. projectName: this.form.ssxm.split(",")[1],
  750. type: this.form.jhlx,
  751. applyMonth: this.form.date,
  752. purchaserId: this.form.fgcgy,
  753. purchaserName:
  754. this.form.fgcgy == ""
  755. ? ""
  756. : this.cgyList.filter(a => a.userId == this.form.fgcgy)[0]
  757. .userName,
  758. applicantId: localStorage.user_id,
  759. applicantName: localStorage.user_name,
  760. attachmentList: this.form.filesList,
  761. remark: this.form.sm
  762. };
  763. this.spinShow = true;
  764. addPurchaseApply(postData).then(res => {
  765. this.spinShow = false;
  766. if (res.status == 200) {
  767. this.$Message.success("新建申购计划成功!");
  768. this.form.bt = res.data.title;
  769. this.form.jhdjh = res.data.code;
  770. this.form.filesList = res.data.attachmentList;
  771. this.id = res.data.id;
  772. this.planType = "edit";
  773. let getData = {
  774. areaId: res.data.areaId,
  775. projectId: res.data.projectId
  776. };
  777. warehouseList(getData).then(res => {
  778. if (res.status == 200) {
  779. this.ckList = res.data;
  780. }
  781. });
  782. } else {
  783. this.$Message.error(res.message);
  784. }
  785. });
  786. } else {
  787. this.editSgjh();
  788. }
  789. },
  790. editSgjh() {
  791. for (let i in this.tableData) {
  792. if (this.tableData[i].storehouseId == "") {
  793. this.$Message.error("请选择计划明细仓库!");
  794. return false;
  795. }
  796. if (this.tableData[i].amount <= 0) {
  797. this.$Message.error("计划明细申购数量不能小于或等于0!");
  798. return false;
  799. }
  800. // if (this.tableData[i].billType == "") {
  801. // this.$Message.error("请选择计划明细单据类型!");
  802. // return false;
  803. // }
  804. this.tableData[i].referenceTotalPrice = (
  805. this.tableData[i].amount * this.tableData[i].referencePrice
  806. ).toFixed(2);
  807. this.tableData[i].storehouseName = this.ckList.filter(
  808. a => a.twId == this.tableData[i].storehouseId
  809. )[0].twName;
  810. }
  811. // for (let i in this.tableData) {
  812. // this.tableData[i].amount = Number(this.tableData[i].amount).toFixed(2);
  813. // }
  814. let postData = {
  815. areaId: this.form.ssqy.split(",")[0],
  816. areaName: this.form.ssqy.split(",")[1],
  817. projectId: this.form.ssxm.split(",")[0],
  818. projectName: this.form.ssxm.split(",")[1],
  819. type: this.form.jhlx,
  820. applyMonth: this.form.date,
  821. purchaserId: this.form.fgcgy,
  822. purchaserName:
  823. this.form.fgcgy == ""
  824. ? ""
  825. : this.cgyList.filter(a => a.userId == this.form.fgcgy)[0].userName,
  826. applicantId: localStorage.user_id,
  827. applicantName: localStorage.user_name,
  828. attachmentList: this.form.filesList,
  829. remark: this.form.sm,
  830. id: this.id,
  831. detailList: this.tableData
  832. };
  833. this.spinShow = true;
  834. return new Promise((resolve, reject) => {
  835. editPurchaseApply(postData).then(res => {
  836. this.spinShow = false;
  837. if (res.status == 200) {
  838. this.$Message.success("编辑申购计划成功!");
  839. this.getSgjh(this.id);
  840. resolve();
  841. // this.cancel();
  842. } else {
  843. this.$Message.error(res.message);
  844. reject();
  845. }
  846. });
  847. });
  848. },
  849. tableOnSelect(selection, row) {
  850. this.tableSelect = selection;
  851. },
  852. tableOnCancel(selection, row) {
  853. this.tableSelect = selection;
  854. },
  855. //审批记录跳转
  856. toSpjl() {
  857. let link = `http://gdoa1.kingser.com:88/westvalley/PSWorkflow/PSWorkflowDecode.jsp?loginmsg=bG9naW5pZD1wbXMmdXNlcnBhc3N3b3JkPVBBYjEyMzQ1Nio=&requestid=${this.requestId}`;
  858. window.open(link);
  859. },
  860. submitSgjh() {
  861. let cango = true;
  862. for (let i in this.tableData) {
  863. if (this.tableData[i].storehouseId == "") {
  864. cango = false;
  865. this.$Message.error("请选择计划明细仓库!");
  866. return false;
  867. }
  868. this.tableData[i].referenceTotalPrice = (
  869. this.tableData[i].amount * this.tableData[i].referencePrice
  870. ).toFixed(2);
  871. this.tableData[i].storehouseName = this.ckList.filter(
  872. a => a.twId == this.tableData[i].storehouseId
  873. )[0].twName;
  874. }
  875. if (!cango) {
  876. return false;
  877. }
  878. this.spinShow = true;
  879. this.editSgjh().then(() => {
  880. console.log(123);
  881. let postData = {
  882. id: this.id
  883. };
  884. submitPurchaseApply(postData).then(res => {
  885. this.spinShow = false;
  886. if (res.status == 200) {
  887. this.$Message.success("提交申购计划成功!");
  888. this.form.spzt = "1";
  889. } else {
  890. this.$Message.error(res.message);
  891. }
  892. });
  893. });
  894. },
  895. //所属区域切换
  896. ssqyChange(val) {
  897. if (this.form.ssqy) {
  898. let postData = {
  899. areaId: this.form.ssqy.split(",")[0],
  900. userId: localStorage.user_id
  901. };
  902. getProjectList(postData).then(res => {
  903. this.form.ssxm = "";
  904. this.ssxmList = res.items;
  905. });
  906. }
  907. },
  908. deleteRow(index) {
  909. this.tableData.splice(index, 1);
  910. },
  911. cancelRow(row, index) {
  912. if (this.form.sqr != localStorage.user_name) {
  913. this.$Message.error("非计划申请人不允许取消申购计划明细!");
  914. return false;
  915. }
  916. editPurchaseApplyDetailState(row.id).then(res => {
  917. if (res.status == 200) {
  918. this.$Message.success("取消申购计划明细成功!");
  919. this.tableData[index].isCancel = 1;
  920. } else {
  921. this.$Message.error(res.message);
  922. }
  923. });
  924. },
  925. //明细弹窗
  926. addMxShow() {
  927. this.contentShow = true;
  928. this.$refs.add.projectId = this.form.ssxm;
  929. this.$refs.add.documentNo = this.form.jhdjh;
  930. this.$refs.add.getTableData();
  931. },
  932. //返回、取消
  933. cancel() {
  934. this.form = {
  935. jhdjh: "", // 计划单据号
  936. bt: "", //标题
  937. spzt: 0, //审批状态
  938. date: "", //计划月份
  939. ssqy: "", //所属区域
  940. ssxm: "", //所属项目
  941. jhlx: "", //计划类型
  942. fgcgy: "", //分管采购员
  943. totalPrice: 0, //总价
  944. sqr: localStorage.user_name, //申请人
  945. filesList: []
  946. };
  947. this.tableColumn = [
  948. {
  949. type: "selection",
  950. width: 60,
  951. align: "center"
  952. },
  953. {
  954. title: "物料编码",
  955. key: "code",
  956. tooltip: "true",
  957. width: 100
  958. },
  959. {
  960. title: "物料分类",
  961. key: "firstClassName",
  962. tooltip: "true",
  963. width: 100
  964. },
  965. {
  966. title: "物料名称",
  967. key: "materialName",
  968. tooltip: "true",
  969. width: 100
  970. },
  971. {
  972. title: "规格型号",
  973. key: "specs",
  974. tooltip: "true",
  975. width: 100
  976. },
  977. {
  978. title: "单位",
  979. key: "unit",
  980. tooltip: "true",
  981. width: 100
  982. },
  983. {
  984. title: "库存量",
  985. key: "inventory",
  986. tooltip: "true",
  987. width: 100
  988. },
  989. {
  990. title: "申购数量",
  991. slot: "amount",
  992. tooltip: "true",
  993. width: 100
  994. },
  995. {
  996. title: "参考单价(元)",
  997. key: "referencePrice",
  998. tooltip: "true",
  999. width: 120
  1000. },
  1001. {
  1002. title: "参考总价(元)",
  1003. slot: "referenceTotalPrice",
  1004. tooltip: "true",
  1005. width: 120
  1006. },
  1007. {
  1008. title: "入库仓库",
  1009. slot: "storehouseId",
  1010. tooltip: "true",
  1011. width: 100
  1012. },
  1013. {
  1014. title: "对接人",
  1015. slot: "linkedPersonName",
  1016. tooltip: "true",
  1017. width: 100
  1018. },
  1019. // {
  1020. // title: "单据类型",
  1021. // slot: "billType",
  1022. // tooltip: "true",
  1023. // width: 100
  1024. // },
  1025. {
  1026. title: "计划到货时间",
  1027. slot: "arriveTime",
  1028. tooltip: "true",
  1029. width: 130
  1030. },
  1031. {
  1032. title: "备注",
  1033. slot: "remark",
  1034. tooltip: "true",
  1035. width: 150
  1036. },
  1037. {
  1038. title: "操作",
  1039. slot: "cz",
  1040. tooltip: "true",
  1041. width: 60
  1042. }
  1043. ];
  1044. this.id = "";
  1045. this.tableData = [];
  1046. this.tableSelect = [];
  1047. this.planType = "add";
  1048. this.spinShow = false;
  1049. this.$emit("return");
  1050. }
  1051. },
  1052. watch: {
  1053. ssqyList(val) {
  1054. if (val && val.length && val.length === 1) {
  1055. const [{ areaId, areaName }] = val;
  1056. this.form.ssqy = `${areaId},${areaName}`;
  1057. this.ssqyChange();
  1058. }
  1059. },
  1060. ssxmList(val) {
  1061. if (val && val.length && val.length === 1) {
  1062. console.log("change");
  1063. const [{ projectId, projectName }] = val;
  1064. this.form.ssxm = `${projectId},${projectName}`;
  1065. }
  1066. },
  1067. tableData: {
  1068. handler(val, name) {
  1069. // console.log(val, 11111111111111111);
  1070. let total = 0;
  1071. let str = "";
  1072. for (let item in val) {
  1073. if (val[item].isCancel) {
  1074. } else {
  1075. total += val[item].referencePrice * val[item].amount;
  1076. }
  1077. }
  1078. this.form.totalPrice = Number(total).toFixed(2);
  1079. },
  1080. deep: true
  1081. }
  1082. }
  1083. };
  1084. </script>
  1085. <style lang="scss" scoped>
  1086. .mustSpan {
  1087. color: red;
  1088. margin-left: 2px;
  1089. }
  1090. button {
  1091. min-width: 80px;
  1092. }
  1093. .uplCont {
  1094. border-left: 1px solid #e4e4e4;
  1095. .upl {
  1096. flex: auto;
  1097. border-right: 1px solid #e4e4e4;
  1098. &:nth-child(1) {
  1099. background: #f8f9fb;
  1100. display: flex;
  1101. align-items: center;
  1102. justify-content: center;
  1103. }
  1104. }
  1105. .uplf {
  1106. display: flex;
  1107. align-items: center;
  1108. justify-content: center;
  1109. min-height: 80px;
  1110. }
  1111. }
  1112. .mainCont .tables {
  1113. height: 50px;
  1114. border-right: 1px solid #e4e4e4;
  1115. border-bottom: 1px solid #e4e4e4;
  1116. display: flex;
  1117. align-items: center;
  1118. justify-content: center;
  1119. word-break: break-all;
  1120. &:nth-child(2n + 1) {
  1121. background: #f8f9fb;
  1122. }
  1123. }
  1124. .mainCont {
  1125. border-left: 1px solid #e4e4e4;
  1126. border-top: 1px solid #e4e4e4;
  1127. }
  1128. ivu-card-head-inner,
  1129. .ivu-card-head p {
  1130. display: inline-block;
  1131. width: 100%;
  1132. height: 20px;
  1133. line-height: 20px;
  1134. font-size: 14px;
  1135. color: #17233d;
  1136. font-weight: 700;
  1137. overflow: hidden;
  1138. text-overflow: ellipsis;
  1139. white-space: nowrap;
  1140. font-weight: normal;
  1141. }
  1142. </style>