planAdd.vue 38 KB

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