planAdd.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215
  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" :disabled="submitLoading">返回</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" style="padding: 10px 0">
  124. <Input v-model="form.sm" :disabled="form.spzt == '2' || form.spzt == '1'" placeholder="请输入" type="textarea"
  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 border
  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="0" :precision="2" :active-change="false" 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. resizable: true,
  339. },
  340. {
  341. type: "index",
  342. title: "序号",
  343. width: 60,
  344. align: "center",
  345. resizable: true,
  346. },
  347. {
  348. title: "物料编码",
  349. key: "code",
  350. tooltip: true,
  351. width: 180,
  352. resizable: true,
  353. },
  354. {
  355. title: "物料分类",
  356. key: "firstClassName",
  357. tooltip: true,
  358. width: 100,
  359. resizable: true,
  360. },
  361. {
  362. title: "物料名称",
  363. key: "materialName",
  364. tooltip: true,
  365. width: 100,
  366. resizable: true,
  367. },
  368. {
  369. title: "规格型号",
  370. key: "specs",
  371. tooltip: true,
  372. width: 100,
  373. resizable: true,
  374. },
  375. {
  376. title: "单位",
  377. key: "unit",
  378. tooltip: true,
  379. width: 100,
  380. resizable: true,
  381. },
  382. {
  383. title: "库存量",
  384. key: "inventory",
  385. tooltip: true,
  386. width: 100,
  387. resizable: true,
  388. },
  389. {
  390. title: "申购数量",
  391. slot: "amount",
  392. tooltip: true,
  393. width: 100,
  394. resizable: true,
  395. },
  396. {
  397. title: "参考单价(元)",
  398. key: "referencePrice",
  399. tooltip: true,
  400. width: 120,
  401. resizable: true,
  402. },
  403. {
  404. title: "参考总价(元)",
  405. slot: "referenceTotalPrice",
  406. tooltip: true,
  407. width: 120,
  408. resizable: true,
  409. },
  410. {
  411. title: "入库仓库",
  412. slot: "storehouseId",
  413. tooltip: true,
  414. width: 100,
  415. resizable: true,
  416. },
  417. {
  418. title: "对接人",
  419. slot: "linkedPersonId",
  420. tooltip: true,
  421. width: 100,
  422. resizable: true,
  423. },
  424. // {
  425. // title: "单据类型",
  426. // slot: "billType",
  427. // tooltip: true,
  428. // width: 100
  429. // },
  430. {
  431. title: "计划到货时间",
  432. slot: "arriveTime",
  433. tooltip: true,
  434. width: 130,
  435. resizable: true,
  436. },
  437. {
  438. title: "备注",
  439. slot: "remark",
  440. tooltip: true,
  441. width: 150,
  442. resizable: true,
  443. },
  444. // {
  445. // title: "状态",
  446. // slot: "isCancel",
  447. // tooltip: true,
  448. // width: 100
  449. // },
  450. {
  451. title: "操作",
  452. slot: "cz",
  453. tooltip: true,
  454. width: 80,
  455. resizable: true,
  456. },
  457. ],
  458. tableData: [],
  459. tableSelect: [],
  460. tableLoading: false,
  461. };
  462. },
  463. created() {
  464. // getLabelByCode4Purchase({ dictCode: "billType" }).then(res => {
  465. // if (res.status == 200) {
  466. // this.djList = res.data;
  467. // } else {
  468. // this.$Message.error(res.message);
  469. // }
  470. // });
  471. },
  472. methods: {
  473. //批量设置弹窗
  474. plszOpen() {
  475. if (!this.tableSelect.length) {
  476. this.$Message.error("请至少选择一条物料明细!");
  477. return false;
  478. } else {
  479. this.plszShow = true;
  480. }
  481. },
  482. plszOk() {
  483. let ck = this.plrkck ? this.plrkck : "";
  484. let sj = this.pldhsj ? this.pldhsj : "";
  485. let select = this.tableSelect;
  486. for (let item in this.tableData) {
  487. let id = this.tableData[item].id;
  488. if (select.filter((a) => a.id == id).length > 0) {
  489. if (ck != "") {
  490. this.tableData[item].storehouseId = ck;
  491. }
  492. if (sj != "") {
  493. this.tableData[item].arriveTime = sj;
  494. }
  495. }
  496. }
  497. },
  498. plszCancel() {},
  499. //表单上传
  500. beforeUpload() {},
  501. upFilesLoading() {
  502. this.uploading = true;
  503. },
  504. uploadFilesSuccess(response, file, fileList) {
  505. this.uploading = false;
  506. this.form.filesList.push({
  507. fileName: response.data.fileName,
  508. filePath: response.data.filePath,
  509. fileDetailType: "",
  510. });
  511. },
  512. plAdd(list) {
  513. this.contentShow = false;
  514. for (let item in list) {
  515. if (
  516. this.tableData.filter((a) => a.materialId == list[item].materialId)
  517. .length > 0
  518. ) {} else {
  519. if (this.ckList.length == 1) {
  520. list.forEach((a) => (a.storehouseId = this.ckList[0].twId));
  521. }
  522. this.tableData.push(list[item]);
  523. }
  524. }
  525. },
  526. //查询申购计划详情
  527. getSgjh(id, arr) {
  528. this.id = id;
  529. let postData = {
  530. id: id,
  531. };
  532. this.spinShow = true;
  533. queryPurchaseApplyInfo(postData).then((res) => {
  534. this.spinShow = false;
  535. if (res.status == 200) {
  536. this.form.jhdjh = res.data.code;
  537. this.form.bt = res.data.title;
  538. this.form.ssqy = `${res.data.areaId},${res.data.areaName}`;
  539. this.form.ssxm = `${res.data.projectId},${res.data.projectName}`;
  540. this.form.jhlx = res.data.type;
  541. this.form.date = res.data.applyMonth;
  542. // this.form.fgcgy = res.data.purchaserName;
  543. this.form.sqr = res.data.applicantName;
  544. this.form.spzt = res.data.applyStatus;
  545. if (res.data.applyStatus == "2") {
  546. this.tableColumn = [{
  547. type: "selection",
  548. width: 60,
  549. align: "center",
  550. resizable: true,
  551. },
  552. {
  553. type: "index",
  554. title: "序号",
  555. width: 60,
  556. align: "center",
  557. resizable: true,
  558. },
  559. {
  560. title: "物料编码",
  561. key: "code",
  562. tooltip: true,
  563. width: 180,
  564. resizable: true,
  565. },
  566. {
  567. title: "物料分类",
  568. key: "firstClassName",
  569. tooltip: true,
  570. width: 100,
  571. resizable: true,
  572. },
  573. {
  574. title: "物料名称",
  575. key: "materialName",
  576. tooltip: true,
  577. width: 100,
  578. resizable: true,
  579. },
  580. {
  581. title: "规格型号",
  582. key: "specs",
  583. tooltip: true,
  584. width: 100,
  585. resizable: true,
  586. },
  587. {
  588. title: "单位",
  589. key: "unit",
  590. tooltip: true,
  591. width: 100,
  592. resizable: true,
  593. },
  594. {
  595. title: "库存量",
  596. key: "inventory",
  597. tooltip: true,
  598. width: 100,
  599. resizable: true,
  600. },
  601. {
  602. title: "申购数量",
  603. slot: "amount",
  604. tooltip: true,
  605. width: 100,
  606. resizable: true,
  607. },
  608. {
  609. title: "参考单价(元)",
  610. key: "referencePrice",
  611. tooltip: true,
  612. width: 120,
  613. resizable: true,
  614. },
  615. {
  616. title: "参考总价(元)",
  617. slot: "referenceTotalPrice",
  618. tooltip: true,
  619. width: 120,
  620. resizable: true,
  621. },
  622. {
  623. title: "入库仓库",
  624. slot: "storehouseId",
  625. tooltip: true,
  626. width: 100,
  627. resizable: true,
  628. },
  629. {
  630. title: "对接人",
  631. slot: "linkedPersonId",
  632. tooltip: true,
  633. width: 100,
  634. resizable: true,
  635. },
  636. // {
  637. // title: "单据类型",
  638. // slot: "billType",
  639. // tooltip: true,
  640. // width: 100
  641. // },
  642. {
  643. title: "计划到货时间",
  644. slot: "arriveTime",
  645. tooltip: true,
  646. width: 130,
  647. resizable: true,
  648. },
  649. {
  650. title: "备注",
  651. slot: "remark",
  652. tooltip: true,
  653. width: 150,
  654. resizable: true,
  655. },
  656. {
  657. title: "状态",
  658. slot: "isCancel",
  659. tooltip: true,
  660. width: 100,
  661. resizable: true,
  662. },
  663. {
  664. title: "操作",
  665. slot: "cz",
  666. tooltip: true,
  667. width: 80,
  668. resizable: true,
  669. },
  670. ];
  671. }
  672. this.form.status = res.data.status;
  673. this.form.fgcgy = `${res.data.purchaserId}`;
  674. this.form.ylh = res.data.gpUnionpayNo;
  675. this.form.sf = res.data.gpProvince;
  676. this.form.yb = res.data.gpPostalCode;
  677. this.form.email = res.data.gpEmail;
  678. this.form.fax = res.data.gpFax;
  679. this.form.filesList = res.data.attachmentList;
  680. this.form.sm = res.data.remark;
  681. this.requestId = res.data.requestId;
  682. let docData = {
  683. projectId: res.data.projectId,
  684. };
  685. getDockUserList(docData).then((res) => {
  686. this.djrList = res.data;
  687. });
  688. let postData = {
  689. areaId: this.form.ssqy.split(",")[0],
  690. userId: localStorage.user_id,
  691. };
  692. getProjectList(postData).then((res) => {
  693. this.ssxmList = res.items;
  694. });
  695. let getData = {
  696. areaId: res.data.areaId,
  697. projectId: res.data.projectId,
  698. };
  699. warehouseList(getData).then((res) => {
  700. if (res.status == 200) {
  701. for (let i in res.data) {
  702. res.data[i].twId = res.data[i].twId;
  703. }
  704. this.ckList = res.data;
  705. }
  706. });
  707. if (arr) {
  708. this.tableData = arr;
  709. } else {
  710. this.tableData = res.data.detailList;
  711. }
  712. }
  713. });
  714. },
  715. //新增申购计划
  716. addSgjh() {
  717. let mustArr = ["ssqy", "ssxm", "jhlx", "date", "fgcgy"];
  718. for (let i in mustArr) {
  719. if (!this.form[mustArr[i]]) {
  720. this.$Message.error("请将信息填写完整!");
  721. return false;
  722. }
  723. if (this.form[mustArr[i]] == "" || this.form[mustArr[i]].length == 0) {
  724. this.$Message.error("请将信息填写完整!");
  725. return false;
  726. }
  727. }
  728. if (this.planType == "add") {
  729. let postData = {
  730. areaId: this.form.ssqy.split(",")[0],
  731. areaName: this.form.ssqy.split(",")[1],
  732. projectId: this.form.ssxm.split(",")[0],
  733. projectName: this.form.ssxm.split(",")[1],
  734. type: this.form.jhlx,
  735. applyMonth: this.form.date,
  736. purchaserId: this.form.fgcgy,
  737. purchaserName: this.form.fgcgy == "" ?
  738. "" : this.cgyList.filter((a) => a.userId == this.form.fgcgy)[0]
  739. .userName,
  740. applicantId: localStorage.user_id,
  741. applicantName: localStorage.user_name,
  742. attachmentList: this.form.filesList,
  743. remark: this.form.sm,
  744. };
  745. this.spinShow = true;
  746. addPurchaseApply(postData).then((res) => {
  747. this.spinShow = false;
  748. if (res.status == 200) {
  749. this.$Message.success("新建申购计划成功!");
  750. // this.form.bt = res.data.title;
  751. // this.form.jhdjh = res.data.code;
  752. // this.form.filesList = res.data.attachmentList;
  753. this.id = res.data.id;
  754. this.planType = "edit";
  755. this.getSgjh(this.id);
  756. // let getData = {
  757. // areaId: res.data.areaId,
  758. // projectId: res.data.projectId
  759. // };
  760. // warehouseList(getData).then(res => {
  761. // if (res.status == 200) {
  762. // this.ckList = res.data;
  763. // }
  764. // });
  765. } else {
  766. this.$Message.error(res.message);
  767. }
  768. });
  769. } else {
  770. this.editSgjh();
  771. }
  772. },
  773. editSgjh() {
  774. for (let i in this.tableData) {
  775. if (this.tableData[i].storehouseId == "") {
  776. this.$Message.error("请选择计划明细仓库!");
  777. return false;
  778. }
  779. if (this.tableData[i].amount <= 0) {
  780. this.$Message.error("计划明细申购数量不能小于或等于0!");
  781. return false;
  782. }
  783. // if (this.tableData[i].billType == "") {
  784. // this.$Message.error("请选择计划明细单据类型!");
  785. // return false;
  786. // }
  787. this.tableData[i].referenceTotalPrice = (
  788. this.tableData[i].amount * this.tableData[i].referencePrice
  789. ).toFixed(3);
  790. this.tableData[i].storehouseName = this.ckList.filter(
  791. (a) => a.twId == this.tableData[i].storehouseId
  792. )[0].twName;
  793. }
  794. // for (let i in this.tableData) {
  795. // this.tableData[i].amount = Number(this.tableData[i].amount).toFixed(3);
  796. // }
  797. let postData = {
  798. areaId: this.form.ssqy.split(",")[0],
  799. areaName: this.form.ssqy.split(",")[1],
  800. projectId: this.form.ssxm.split(",")[0],
  801. projectName: this.form.ssxm.split(",")[1],
  802. type: this.form.jhlx,
  803. applyMonth: this.form.date,
  804. purchaserId: this.form.fgcgy,
  805. purchaserName: this.form.fgcgy == "" ?
  806. "" : this.cgyList.filter((a) => a.userId == this.form.fgcgy)[0]
  807. .userName,
  808. applicantId: localStorage.user_id,
  809. applicantName: localStorage.user_name,
  810. attachmentList: this.form.filesList,
  811. remark: this.form.sm,
  812. id: this.id,
  813. detailList: this.tableData,
  814. };
  815. this.spinShow = true;
  816. return new Promise((resolve, reject) => {
  817. editPurchaseApply(postData).then((res) => {
  818. this.spinShow = false;
  819. if (res.status == 200) {
  820. this.$Message.success("编辑申购计划成功!");
  821. this.getSgjh(this.id);
  822. resolve();
  823. // this.cancel();
  824. } else {
  825. this.$Message.error(res.message);
  826. reject();
  827. }
  828. });
  829. });
  830. },
  831. tableOnSelect(selection, row) {
  832. this.tableSelect = selection;
  833. },
  834. tableOnCancel(selection, row) {
  835. this.tableSelect = selection;
  836. },
  837. //审批记录跳转
  838. toSpjl() {
  839. let link =
  840. `http://oa.kingser.com:88/westvalley/PSWorkflow/PSWorkflowDecode.jsp?loginmsg=bG9naW5pZD1wbXMmdXNlcnBhc3N3b3JkPVBBYjEyMzQ1Nio=&requestid=${this.requestId}`;
  841. window.open(link);
  842. },
  843. submitSgjh() {
  844. if (this.submitLoading) {
  845. return false;
  846. }
  847. let cango = true;
  848. for (let i in this.tableData) {
  849. if (this.tableData[i].storehouseId == "") {
  850. cango = false;
  851. this.$Message.error("请选择计划明细仓库!");
  852. return false;
  853. }
  854. if (this.tableData[i].amount <= 0) {
  855. this.$Message.error("计划明细申购数量不能小于或等于0!");
  856. cango = false;
  857. return false;
  858. }
  859. this.tableData[i].referenceTotalPrice = (
  860. this.tableData[i].amount * this.tableData[i].referencePrice
  861. ).toFixed(3);
  862. this.tableData[i].storehouseName = this.ckList.filter(
  863. (a) => a.twId == this.tableData[i].storehouseId
  864. )[0].twName;
  865. }
  866. if (!cango) {
  867. return false;
  868. }
  869. this.spinShow = true;
  870. this.submitLoading = true;
  871. this.editSgjh()
  872. .then(() => {
  873. let postData = {
  874. id: this.id,
  875. };
  876. submitPurchaseApply(postData).then((res) => {
  877. this.submitLoading = false;
  878. this.spinShow = false;
  879. if (res.status == 200) {
  880. this.$Message.success("提交申购计划成功!");
  881. this.getSgjh(this.id);
  882. } else {
  883. this.$Message.error(res.message);
  884. }
  885. });
  886. })
  887. .catch(() => {
  888. this.submitLoading = false;
  889. this.spinShow = false;
  890. });
  891. },
  892. //对接人选择
  893. djrChange(val, index) {
  894. // console.log(val, index);
  895. this.tableData[index].linkedPersonName = val.label;
  896. },
  897. //所属区域切换
  898. ssqyChange(val) {
  899. if (this.form.ssqy) {
  900. let postData = {
  901. areaId: this.form.ssqy.split(",")[0],
  902. userId: localStorage.user_id,
  903. };
  904. getProjectList(postData).then((res) => {
  905. this.form.ssxm = "";
  906. this.ssxmList = res.items;
  907. });
  908. }
  909. },
  910. deleteRow(index) {
  911. this.tableData.splice(index, 1);
  912. },
  913. qxOk() {
  914. if (this.qxsm == "") {
  915. this.$Message.error("请填写取消说明");
  916. return false;
  917. } else {
  918. let postData = {
  919. purchaseApplyDetailId: this.qxrow.id,
  920. cancelReason: this.qxsm,
  921. };
  922. cancelPurchaseApplyDetail(postData).then((res) => {
  923. if (res.status == 200) {
  924. this.$Message.success("取消申购计划明细成功!");
  925. this.tableData[this.qxindex].isCancel = 1;
  926. this.qxCancel();
  927. this.getSgjh(this.id);
  928. } else {
  929. this.$Message.error(res.message);
  930. }
  931. });
  932. }
  933. },
  934. qxCancel() {
  935. this.qxShow = false;
  936. this.qxsm = "";
  937. this.qxindex = null;
  938. this.qxrow = null;
  939. },
  940. cancelRow(row, index) {
  941. if (this.form.sqr != localStorage.user_name) {
  942. this.$Message.error("非计划申请人不允许取消申购计划明细!");
  943. return false;
  944. } else {
  945. this.qxShow = true;
  946. this.qxrow = row;
  947. this.qxindex = index;
  948. }
  949. // editPurchaseApplyDetailState(row.id).then(res => {
  950. // if (res.status == 200) {
  951. // this.$Message.success("取消申购计划明细成功!");
  952. // this.tableData[index].isCancel = 1;
  953. // } else {
  954. // this.$Message.error(res.message);
  955. // }
  956. // });
  957. },
  958. //明细弹窗
  959. addMxShow() {
  960. this.contentShow = true;
  961. this.$refs.add.projectId = this.form.ssxm;
  962. this.$refs.add.documentNo = this.form.jhdjh;
  963. this.$refs.add.getTableData();
  964. },
  965. //返回、取消
  966. cancel() {
  967. this.submitLoading = false;
  968. this.form = {
  969. jhdjh: "", // 计划单据号
  970. bt: "", //标题
  971. spzt: 0, //审批状态
  972. date: "", //计划月份
  973. ssqy: "", //所属区域
  974. ssxm: "", //所属项目
  975. jhlx: "", //计划类型
  976. fgcgy: "", //分管采购员
  977. totalPrice: 0, //总价
  978. sqr: localStorage.user_name, //申请人
  979. filesList: [],
  980. };
  981. this.tableColumn = [{
  982. type: "selection",
  983. width: 60,
  984. align: "center",
  985. resizable: true,
  986. },
  987. {
  988. type: "index",
  989. title: "序号",
  990. width: 60,
  991. align: "center",
  992. resizable: true,
  993. },
  994. {
  995. title: "物料编码",
  996. key: "code",
  997. tooltip: true,
  998. width: 180,
  999. resizable: true,
  1000. },
  1001. {
  1002. title: "物料分类",
  1003. key: "firstClassName",
  1004. tooltip: true,
  1005. width: 100,
  1006. resizable: true,
  1007. },
  1008. {
  1009. title: "物料名称",
  1010. key: "materialName",
  1011. tooltip: true,
  1012. width: 100,
  1013. resizable: true,
  1014. },
  1015. {
  1016. title: "规格型号",
  1017. key: "specs",
  1018. tooltip: true,
  1019. width: 100,
  1020. resizable: true,
  1021. },
  1022. {
  1023. title: "单位",
  1024. key: "unit",
  1025. tooltip: true,
  1026. width: 100,
  1027. resizable: true,
  1028. },
  1029. {
  1030. title: "库存量",
  1031. key: "inventory",
  1032. tooltip: true,
  1033. width: 100,
  1034. resizable: true,
  1035. },
  1036. {
  1037. title: "申购数量",
  1038. slot: "amount",
  1039. tooltip: true,
  1040. width: 100,
  1041. resizable: true,
  1042. },
  1043. {
  1044. title: "参考单价(元)",
  1045. key: "referencePrice",
  1046. tooltip: true,
  1047. width: 120,
  1048. resizable: true,
  1049. },
  1050. {
  1051. title: "参考总价(元)",
  1052. slot: "referenceTotalPrice",
  1053. tooltip: true,
  1054. width: 120,
  1055. resizable: true,
  1056. },
  1057. {
  1058. title: "入库仓库",
  1059. slot: "storehouseId",
  1060. tooltip: true,
  1061. width: 100,
  1062. resizable: true,
  1063. },
  1064. {
  1065. title: "对接人",
  1066. slot: "linkedPersonId",
  1067. tooltip: true,
  1068. width: 100,
  1069. resizable: true,
  1070. },
  1071. // {
  1072. // title: "单据类型",
  1073. // slot: "billType",
  1074. // tooltip: true,
  1075. // width: 100
  1076. // },
  1077. {
  1078. title: "计划到货时间",
  1079. slot: "arriveTime",
  1080. tooltip: true,
  1081. width: 130,
  1082. resizable: true,
  1083. },
  1084. {
  1085. title: "备注",
  1086. slot: "remark",
  1087. tooltip: true,
  1088. width: 150,
  1089. resizable: true,
  1090. },
  1091. {
  1092. title: "操作",
  1093. slot: "cz",
  1094. tooltip: true,
  1095. width: 80,
  1096. resizable: true,
  1097. },
  1098. ];
  1099. this.id = "";
  1100. this.tableData = [];
  1101. this.tableSelect = [];
  1102. this.planType = "add";
  1103. this.spinShow = false;
  1104. this.$emit("return");
  1105. },
  1106. },
  1107. watch: {
  1108. ssqyList(val) {
  1109. if (val && val.length && val.length === 1) {
  1110. const [{
  1111. areaId,
  1112. areaName
  1113. }] = val;
  1114. this.form.ssqy = `${areaId},${areaName}`;
  1115. this.ssqyChange();
  1116. }
  1117. },
  1118. ssxmList(val) {
  1119. if (val && val.length && val.length === 1) {
  1120. console.log("change");
  1121. const [{
  1122. projectId,
  1123. projectName
  1124. }] = val;
  1125. this.form.ssxm = `${projectId},${projectName}`;
  1126. }
  1127. },
  1128. tableData: {
  1129. handler(val, name) {
  1130. // console.log(val, 11111111111111111);
  1131. let total = 0;
  1132. let str = "";
  1133. for (let item in val) {
  1134. if (val[item].isCancel) {} else {
  1135. total += val[item].referencePrice * val[item].amount;
  1136. }
  1137. }
  1138. this.form.totalPrice = Number(total).toFixed(3);
  1139. },
  1140. deep: true,
  1141. },
  1142. },
  1143. };
  1144. </script>
  1145. <style lang="scss" scoped>
  1146. .mustSpan {
  1147. color: red;
  1148. margin-left: 2px;
  1149. }
  1150. button {
  1151. min-width: 80px;
  1152. }
  1153. .uplCont {
  1154. border-left: 1px solid #e4e4e4;
  1155. .upl {
  1156. flex: auto;
  1157. border-right: 1px solid #e4e4e4;
  1158. &:nth-child(1) {
  1159. background: #f8f9fb;
  1160. display: flex;
  1161. align-items: center;
  1162. justify-content: center;
  1163. }
  1164. }
  1165. .uplf {
  1166. display: flex;
  1167. align-items: center;
  1168. justify-content: center;
  1169. min-height: 80px;
  1170. }
  1171. }
  1172. .mainCont .tables {
  1173. min-height: 50px;
  1174. border-right: 1px solid #e4e4e4;
  1175. border-bottom: 1px solid #e4e4e4;
  1176. display: flex;
  1177. align-items: center;
  1178. justify-content: center;
  1179. word-break: break-all;
  1180. &:nth-child(2n + 1) {
  1181. background: #f8f9fb;
  1182. }
  1183. }
  1184. .mainCont {
  1185. border-left: 1px solid #e4e4e4;
  1186. border-top: 1px solid #e4e4e4;
  1187. }
  1188. ivu-card-head-inner,
  1189. .ivu-card-head p {
  1190. display: inline-block;
  1191. width: 100%;
  1192. height: 20px;
  1193. line-height: 20px;
  1194. font-size: 14px;
  1195. color: #17233d;
  1196. font-weight: 700;
  1197. overflow: hidden;
  1198. text-overflow: ellipsis;
  1199. white-space: nowrap;
  1200. font-weight: normal;
  1201. }
  1202. </style>