orderAdd.vue 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354
  1. <template>
  2. <div>
  3. <!-- 页面主体内容 -->
  4. <div class="planAddContent" v-show="contentShow && !printShow">
  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 != '1'" @click="toSpjl">查看审批记录</Button>
  9. <Button @click="submitCgdd" v-if="orderType == 'edit' && form.spzt == '1'">提交</Button>
  10. <Button @click="addCgdd" v-if="form.spzt == '1'">保存</Button>
  11. <Button
  12. href="javascript:;"
  13. v-if="form.ddzt != '6' && form.spzt != '4'"
  14. @click="printRow()"
  15. >打印</Button>
  16. <Button @click="cancel">返回</Button>
  17. </div>
  18. <Row class="mainCont">
  19. <Col span="4" class-name="tables">订购编号</Col>
  20. <Col span="4" class-name="tables">
  21. <span style="color: gray" v-if="orderType == 'add'">系统自动生成,不可编辑</span>
  22. <span v-else>{{ form.dgbh }}</span>
  23. </Col>
  24. <Col span="4" class-name="tables">标题</Col>
  25. <Col span="4" class-name="tables">
  26. <span style="color: gray" v-if="orderType == 'add'">系统自动生成,不可编辑</span>
  27. <span v-else>{{ form.bt }}</span>
  28. </Col>
  29. <Col span="4" class-name="tables">总价(元)</Col>
  30. <Col span="4" class-name="tables">{{ form.totalPrice }}</Col>
  31. <Col span="4" class-name="tables">
  32. 关联区域
  33. <span class="mustSpan">*</span>
  34. </Col>
  35. <Col span="4" class-name="tables">
  36. <Select
  37. clearable
  38. v-model="form.glqy"
  39. style="width: 95%"
  40. v-if="orderType == 'add'"
  41. @on-change="ssqyChange"
  42. >
  43. <Option
  44. v-for="item in glqyList"
  45. :value="item.areaId + ',' + item.areaName"
  46. :key="item.areaId"
  47. :disabled="form.spzt == '2' || form.spzt == '3'"
  48. >{{ item.areaName }}</Option>
  49. </Select>
  50. <span v-else>{{ form.glqy.split(',')[1] }}</span>
  51. </Col>
  52. <Col span="4" class-name="tables">
  53. 关联项目
  54. <span class="mustSpan">*</span>
  55. </Col>
  56. <Col span="4" class-name="tables">
  57. <Select clearable v-model="form.glxm" style="width: 95%" v-if="orderType == 'add'">
  58. <Option
  59. v-for="item in glxmList"
  60. :value="item.projectId + ',' + item.projectName"
  61. :key="item.projectId"
  62. :disabled="form.spzt == '2' || form.spzt == '3'"
  63. >{{ item.projectName }}</Option>
  64. </Select>
  65. <span v-else>{{ form.glxm.split(',')[1] }}</span>
  66. </Col>
  67. <!-- <Col span="4" class-name="tables">
  68. 单据类型
  69. <span class="mustSpan">*</span>
  70. </Col>
  71. <Col span="4" class-name="tables">
  72. <Select v-model="form.djlx" style="width: 95%" :disabled="form.spzt != '1'">
  73. <Option
  74. v-for="item in djlxList"
  75. :value="item.value"
  76. :key="item.value"
  77. >{{ item.label }}</Option>
  78. </Select>
  79. </Col>-->
  80. <Col span="4" class-name="tables">采购人</Col>
  81. <Col span="4" class-name="tables">{{ form.cgr }}</Col>
  82. <Col span="4" class-name="tables">
  83. 采购人联系方式
  84. <span class="mustSpan">*</span>
  85. </Col>
  86. <Col span="4" class-name="tables">
  87. <Input
  88. v-model="form.cgrlxfs"
  89. :disabled="form.spzt != '1'"
  90. placeholder="请输入"
  91. style="width: 95%"
  92. />
  93. </Col>
  94. <Col span="4" class-name="tables">
  95. 下单日期
  96. <span class="mustSpan">*</span>
  97. </Col>
  98. <Col span="4" class-name="tables">
  99. <DatePicker
  100. style="width: 95%"
  101. format="yyyy-MM-dd HH:mm:ss"
  102. :value="form.xdrq"
  103. @on-change="form.xdrq=$event"
  104. type="datetime"
  105. :options="xdrqOption"
  106. placeholder="请选择"
  107. :disabled="form.spzt != '1'"
  108. ></DatePicker>
  109. </Col>
  110. <Col span="4" class-name="tables">
  111. 交货时间
  112. <span class="mustSpan">*</span>
  113. </Col>
  114. <Col span="4" class-name="tables">
  115. <DatePicker
  116. :disabled="form.xdrq == '' || form.spzt != '1'"
  117. style="width: 95%"
  118. format="yyyy-MM-dd"
  119. :value="form.jhsj"
  120. :options="jhsjOptions"
  121. @on-change="form.jhsj=$event"
  122. type="date"
  123. placeholder="请选择"
  124. ></DatePicker>
  125. </Col>
  126. <Col span="4" class-name="tables">交货地点</Col>
  127. <Col span="4" class-name="tables">
  128. <span style="color: gray" v-if="orderType == 'add'">系统自动生成,不可编辑</span>
  129. <span v-else>{{ form.jhdd }}</span>
  130. </Col>
  131. <Col span="4" class-name="tables">
  132. 收货人
  133. <span class="mustSpan">*</span>
  134. </Col>
  135. <Col span="4" class-name="tables">
  136. <Input
  137. v-model="form.shr"
  138. :disabled="form.spzt != '1'"
  139. placeholder="请输入"
  140. style="width: 95%"
  141. />
  142. </Col>
  143. <Col span="4" class-name="tables">
  144. 收货人联系方式
  145. <span class="mustSpan">*</span>
  146. </Col>
  147. <Col span="4" class-name="tables">
  148. <Input
  149. v-model="form.shrlxfs"
  150. :disabled="form.spzt != '1'"
  151. placeholder="请输入"
  152. style="width: 95%"
  153. />
  154. </Col>
  155. <Col span="4" class-name="tables">
  156. 供应商
  157. <span class="mustSpan">*</span>
  158. </Col>
  159. <Col span="12" class-name="tables">
  160. <Select
  161. clearable
  162. v-model="form.gys"
  163. @on-change="gysChange"
  164. placeholder="请选择供应商(如供应商银行信息不完整,则无法选择)"
  165. filterable
  166. style="width: 95%"
  167. v-if="orderType == 'add'"
  168. >
  169. <Option
  170. v-for="item in gysList"
  171. :disabled="form.spzt != '1'"
  172. :value="item.gpId"
  173. :key="item.gpId"
  174. >{{ item.gpName }}</Option>
  175. </Select>
  176. <span v-else>{{ form.gysmc }}</span>
  177. </Col>
  178. <Col span="4" class-name="tables">供方负责人</Col>
  179. <Col span="4" class-name="tables">{{ form.gffzr }}</Col>
  180. <Col span="4" class-name="tables">供应商联系电话</Col>
  181. <Col span="4" class-name="tables">{{ form.gyslxdh }}</Col>
  182. <Col span="4" class-name="tables">关联申购计划</Col>
  183. <Col span="4" class-name="tables">{{ form.glsgjh }}</Col>
  184. <!-- <Col span="4" class-name="tables"></Col>
  185. <Col span="4" class-name="tables"></Col>-->
  186. <Col span="4" class-name="tables">审批状态</Col>
  187. <Col span="4" class-name="tables">
  188. <span v-if="form.spzt == ''">-</span>
  189. <span v-if="form.spzt == '1'">未提交</span>
  190. <span v-if="form.spzt == '2'">审核中</span>
  191. <span v-if="form.spzt == '3'">审核通过</span>
  192. <span v-if="form.spzt == '4'">审核拒绝</span>
  193. </Col>
  194. <Col span="4" class-name="tables">审批通过时间</Col>
  195. <Col span="4" class-name="tables">-</Col>
  196. <Col span="4" class-name="tables">订单状态</Col>
  197. <Col span="4" class-name="tables">
  198. <span v-if="form.ddzt == ''">-</span>
  199. <span v-if="form.ddzt == '1'">未下单</span>
  200. <span v-if="form.ddzt == '2'">待下单</span>
  201. <span v-if="form.ddzt == '3'">已下单</span>
  202. <span v-if="form.ddzt == '4'">入库中</span>
  203. <span v-if="form.ddzt == '5'">已入库</span>
  204. <span v-if="form.ddzt == '6'">已取消</span>
  205. </Col>
  206. <Col span="4" class-name="tables"></Col>
  207. <Col span="4" class-name="tables"></Col>
  208. </Row>
  209. <Row class="uplCont" type="flex" justify="center" style="align-items: stretch">
  210. <Col span="4" class-name="upl">附件</Col>
  211. <Col span="6" class-name="uplf">
  212. <Upload
  213. :headers="uploadHeaders"
  214. style="width: 80%"
  215. multiple
  216. type="drag"
  217. :disabled="form.spzt != '1'"
  218. action="/purchase/common/uploadFile"
  219. :before-upload="beforeUpload"
  220. :on-success="uploadFilesSuccess"
  221. :show-upload-list="false"
  222. :on-progress="upFilesLoading"
  223. >
  224. <!-- :default-file-list="xzwgForm.filesList" -->
  225. <div style="padding: 5px 0">
  226. <Icon type="md-cloud-upload" size="36" style="color: #3399ff"></Icon>
  227. <span>点击或将文件拖拽到这里上传</span>
  228. </div>
  229. </Upload>
  230. </Col>
  231. <Col span="6" class="upl" style="padding: 5px">
  232. <div v-for="(item, index) in form.filesList" :key="index">
  233. <a
  234. :href="item.docUrl ? item.docUrl : 'javascript:void(0);'"
  235. :download="item.fileName"
  236. :target="item.docUrl ? '_blank' : '_self'"
  237. >{{ item.fileName }}</a>
  238. <span
  239. v-if="form.spzt == '1'"
  240. style="float: right; cursor:pointer"
  241. @click="form.filesList.splice(index, 1)"
  242. >x</span>
  243. </div>
  244. <p v-if="uploading" style="text-align: center">上传中...</p>
  245. </Col>
  246. <Col span="4" class-name="upl">
  247. 发票抬头
  248. <span class="mustSpan">*</span>
  249. </Col>
  250. <Col span="4" class-name="upl">
  251. <Select v-model="form.fptt" style="width: 95%" :disabled="form.spzt != '1'">
  252. <Option
  253. v-for="item in fpttList"
  254. :value="item.value"
  255. :key="item.value"
  256. >{{ item.label }}</Option>
  257. </Select>
  258. </Col>
  259. </Row>
  260. <Row class="mainCont">
  261. <Col span="4" class-name="tables">说明</Col>
  262. <Col span="20" class-name="tables">
  263. <Input
  264. v-model="form.sm"
  265. :disabled="form.spzt != '1'"
  266. placeholder="请输入"
  267. style="width: 99%"
  268. />
  269. </Col>
  270. </Row>
  271. <Spin size="large" fix v-if="spinShow"></Spin>
  272. </Card>
  273. <Card style="width:100%" :bordered="false" :dis-hover="true">
  274. <p slot="title">采购明细</p>
  275. <div slot="extra">
  276. <Button
  277. type="primary"
  278. @click="mxAddShow"
  279. :disabled="orderType == 'add' || form.spzt != '1'"
  280. >新增明细</Button>
  281. </div>
  282. <Table
  283. :columns="tableColumn"
  284. style="width: 100%"
  285. :data="tableData"
  286. :loading="tableLoading"
  287. @on-select="tableOnSelect"
  288. >
  289. <template slot-scope="{ row, index }" slot="purchaseNum">
  290. <InputNumber
  291. :min="1"
  292. :precision="2"
  293. :disabled="form.spzt != '1' || row.isCancel == '1'"
  294. v-model="tableData[index].purchaseNum"
  295. placeholder="请输入"
  296. style="width: 95%"
  297. />
  298. </template>
  299. <template slot-scope="{ row, index }" slot="applyRuleCode">
  300. <a @click.prevent="goDetail(74)">{{row.applyRuleCode}}</a>
  301. </template>
  302. <template slot-scope="{ row, index }" slot="price">
  303. <InputNumber
  304. :min="1"
  305. :precision="2"
  306. :disabled="form.spzt != '1'"
  307. v-model="tableData[index].price"
  308. placeholder="请输入"
  309. style="width: 95%"
  310. />
  311. </template>
  312. <template slot-scope="{ row, index }" slot="totalPrice">
  313. <div>{{ (tableData[index].price * tableData[index].purchaseNum).toFixed(2) }}</div>
  314. </template>
  315. <template slot-scope="{ row, index }" slot="plannedArrivalTime">
  316. <DatePicker
  317. :disabled="form.spzt != '1'"
  318. :transfer="true"
  319. format="yyyy-MM-dd HH:mm:ss"
  320. type="datetime"
  321. :options="xdrqOption"
  322. :value="tableData[index].plannedArrivalTime"
  323. @on-change="tableData[index].plannedArrivalTime=$event"
  324. placeholder="请选择"
  325. style="width: 95%"
  326. ></DatePicker>
  327. </template>
  328. <template slot-scope="{ row, index }" slot="isNumControl">
  329. <RadioGroup v-model="tableData[index].isNumControl">
  330. <Radio :label="0" :disabled="form.spzt != '1'">
  331. <span>是</span>
  332. </Radio>
  333. <Radio :label="1" :disabled="form.spzt != '1'">
  334. <span>否</span>
  335. </Radio>
  336. </RadioGroup>
  337. </template>
  338. <template slot-scope="{ row, index }" slot="isTimeControl">
  339. <RadioGroup v-model="tableData[index].isTimeControl">
  340. <Radio :label="0" :disabled="form.spzt != '1'">
  341. <span>是</span>
  342. </Radio>
  343. <Radio :label="1" :disabled="form.spzt != '1'">
  344. <span>否</span>
  345. </Radio>
  346. </RadioGroup>
  347. </template>
  348. <template slot-scope="{ row, index }" slot="remark">
  349. <Input
  350. :disabled="form.spzt != '1'"
  351. :maxlength="200"
  352. v-model="tableData[index].remark"
  353. placeholder="请输入"
  354. style="width: 95%"
  355. />
  356. </template>
  357. <template
  358. slot-scope="{ row, index }"
  359. slot="isCancel"
  360. >{{ row.isCancel == '0' ? '有效' : '已取消' }}</template>
  361. <template slot-scope="{ row, index }" slot="cz">
  362. <div v-if="form.spzt == '1'">
  363. <a href="javascript:;" v-if="form.spzt == '1'" @click="deleteRow(index)">删除</a>
  364. </div>
  365. <div v-if="row.isCancel == '0' && form.spzt == '3'">
  366. <a href="javascript:;" @click="cancelRow(row, index)">取消</a>
  367. </div>
  368. </template>
  369. </Table>
  370. </Card>
  371. </div>
  372. <!-- 计划明细新增 -->
  373. <orderMxAdd ref="mxAdd" @plAdd="plAdd" @return="contentShow = true" v-show="!contentShow" />
  374. <orderPrint ref="print" @return="() => {printShow = false;}" v-show="printShow" />
  375. </div>
  376. </template>
  377. <script>
  378. import { phoneFun } from "../../../../../config/util";
  379. import {
  380. addPurchaseOrder,
  381. findPurchaseOrder,
  382. editPurchaseOrder,
  383. getLabelByCode,
  384. getProjectList,
  385. submitPurchaseOrder,
  386. getLabelByCode4Purchase,
  387. selectGoodProviderSelectionList,
  388. queryPurchaseApplyInfo,
  389. editPurchaseOrderDetailState
  390. } from "@/service/getData";
  391. import orderMxAdd from "./orderMxAdd";
  392. import orderPrint from "./orderPrint";
  393. export default {
  394. name: "orderAdd",
  395. props: ["glqyList"],
  396. components: {
  397. orderMxAdd,
  398. orderPrint
  399. },
  400. data() {
  401. return {
  402. orderType: "add",
  403. orderId: "",
  404. requestId: "",
  405. uploadHeaders: {
  406. token: localStorage.token,
  407. userId: localStorage.user_id
  408. },
  409. spinShow: false,
  410. contentShow: true,
  411. printShow: false,
  412. form: {
  413. dgbh: "", //订购编号
  414. bt: "", //标题
  415. glqy: "", //关联区域
  416. glxm: "", //关联项目
  417. cgr: localStorage.user_name, //采购人
  418. cgrlxfs: "", //采购人联系方式
  419. xdrq: "", //下单日期
  420. jhsj: "", //交货时间
  421. jhdd: "", //交货地点
  422. shr: "", //收货人
  423. shrlxfs: "", //收货人联系方式
  424. djlx: "", //单据类型
  425. gys: "", //供应商
  426. gysmc: "", //供应商名称
  427. gffzr: "", //供方负责人
  428. gyslxdh: "", //供应商联系电话
  429. totalPrice: 0, //总价
  430. sm: "", //说明
  431. spzt: 1, //审批状态
  432. fptt: "", //发票抬头
  433. sptgsj: "", //审批通过时间
  434. ddzt: 1, //订单状态
  435. glsgjh: "", //关联申购计划
  436. filesList: []
  437. },
  438. gysGo: true,
  439. jhsjOptions: {
  440. disabledDate: date => {
  441. return date && date.valueOf() < new Date(this.form.xdrq);
  442. }
  443. },
  444. xdrqOption: {
  445. disabledDate: date => {
  446. let nDate = new Date();
  447. let dn = +new Date(
  448. `${nDate.getFullYear()}-${nDate.getMonth() + 1}-${nDate.getDate()}`
  449. );
  450. return date.valueOf() < dn;
  451. }
  452. },
  453. // glqyList: [{ label: "test", value: 1 }],
  454. glxmList: [],
  455. cgrList: [{ label: "test", value: 1 }],
  456. djlxList: [],
  457. gysList: [],
  458. fpttList: [],
  459. gffzrList: [{ label: "test", value: 1 }],
  460. uploading: false,
  461. // 批量设置
  462. plszShow: false,
  463. plrkck: "",
  464. pldhsj: "",
  465. // table
  466. tableColumn: [
  467. {
  468. title: "申购计划",
  469. slot: "applyRuleCode",
  470. tooltip: "true",
  471. width: 100
  472. },
  473. {
  474. title: "物料编码",
  475. key: "code",
  476. tooltip: "true",
  477. width: 100
  478. },
  479. {
  480. title: "物料分类",
  481. key: "firstClassName",
  482. tooltip: "true",
  483. width: 100
  484. },
  485. {
  486. title: "物料名称",
  487. key: "materialName",
  488. tooltip: "true",
  489. width: 200
  490. },
  491. {
  492. title: "规格型号",
  493. key: "specs",
  494. tooltip: "true",
  495. width: 100
  496. },
  497. {
  498. title: "单位",
  499. key: "unit",
  500. tooltip: "true",
  501. width: 100
  502. },
  503. {
  504. title: "计划数量",
  505. key: "amount",
  506. tooltip: "true",
  507. width: 100
  508. },
  509. {
  510. title: "已下订数量",
  511. key: "billedAmount",
  512. tooltip: "true",
  513. width: 100
  514. },
  515. {
  516. title: "累计入库数量",
  517. key: "warehousedNum",
  518. tooltip: "true",
  519. width: 120
  520. },
  521. {
  522. title: "待采购数量",
  523. key: "applySurplusNum",
  524. tooltip: "true",
  525. width: 120
  526. },
  527. {
  528. title: "采购数量",
  529. slot: "purchaseNum",
  530. tooltip: "true",
  531. width: 100
  532. },
  533. {
  534. title: "单价(元)",
  535. slot: "price",
  536. tooltip: "true",
  537. width: 100
  538. },
  539. {
  540. title: "总价(元)",
  541. slot: "totalPrice",
  542. tooltip: "true",
  543. width: 100
  544. },
  545. {
  546. title: "入库仓库",
  547. key: "storehouseName",
  548. tooltip: "true",
  549. width: 130
  550. },
  551. {
  552. title: "计划到货时间",
  553. slot: "plannedArrivalTime",
  554. tooltip: "true",
  555. width: 150
  556. },
  557. {
  558. title: "数量管控",
  559. slot: "isNumControl",
  560. tooltip: "true",
  561. width: 100
  562. },
  563. {
  564. title: "时间管控",
  565. slot: "isTimeControl",
  566. tooltip: "true",
  567. width: 100
  568. },
  569. {
  570. title: "备注",
  571. slot: "remark",
  572. tooltip: "true",
  573. width: 100
  574. },
  575. {
  576. title: "操作",
  577. slot: "cz",
  578. tooltip: "true",
  579. width: 60
  580. }
  581. ],
  582. tableData: [],
  583. tableSelect: [],
  584. deleteIds: [],
  585. tableLoading: false
  586. };
  587. },
  588. created() {
  589. getLabelByCode4Purchase({ dictCode: "billType" }).then(res => {
  590. if (res.status == 200) {
  591. this.djlxList = res.data;
  592. } else {
  593. this.$Message.error(res.message);
  594. }
  595. });
  596. getLabelByCode4Purchase({ dictCode: "invoiceTitle" }).then(res => {
  597. if (res.status == 200) {
  598. this.fpttList = res.data;
  599. } else {
  600. this.$Message.error(res.message);
  601. }
  602. });
  603. selectGoodProviderSelectionList({ isCheck: true }).then(res => {
  604. this.gysList = res.data;
  605. });
  606. },
  607. methods: {
  608. goDetail(id) {
  609. let routeUrl = this.$router.resolve({
  610. path: "/viewPurchaseApply",
  611. query: {
  612. id: id
  613. }
  614. });
  615. window.open(routeUrl.href, "_blank");
  616. // window.open(
  617. // `https://test.hajwy.com/purchase-web/#/viewPurchaseApply?id=${id}`
  618. // );
  619. // this.$router.push(`/viewPurchaseApply?code=${code}`)
  620. },
  621. //批量设置弹窗
  622. plszOpen() {
  623. this.plszShow = true;
  624. },
  625. plszOk() {},
  626. plszCancel() {},
  627. //表单上传
  628. beforeUpload() {},
  629. upFilesLoading() {
  630. this.uploading = true;
  631. },
  632. uploadFilesSuccess(response, file, fileList) {
  633. this.uploading = false;
  634. this.form.filesList.push({
  635. fileName: response.data.fileName,
  636. filePath: response.data.filePath,
  637. fileDetailType: ""
  638. });
  639. },
  640. //供应商切换
  641. gysChange(val) {
  642. this.gysGo = true;
  643. let gys = this.gysList.filter(a => a.gpId == val);
  644. if (gys.length > 0) {
  645. let sup = gys[0];
  646. if (!sup.gpcName || !sup.gpcPhone) {
  647. this.$Message.error(
  648. "该供应商用户信息不完整,请完善该供应商信息再选择此供应商!"
  649. );
  650. this.gysGo = false;
  651. this.form.gffzr = "";
  652. this.form.gyslxdh = "";
  653. return false;
  654. }
  655. this.form.gffzr = sup.gpcName;
  656. this.form.gyslxdh = sup.gpcPhone;
  657. // bank开户行 unionpay银行账号
  658. }
  659. },
  660. //所属区域切换
  661. ssqyChange() {
  662. let postData = {
  663. areaId: this.form.glqy.split(",")[0],
  664. userId: localStorage.user_id
  665. };
  666. getProjectList(postData).then(res => {
  667. this.form.glxm = "";
  668. this.glxmList = res.items;
  669. });
  670. },
  671. //获取采购订单详情
  672. getCgddXq(id) {
  673. this.orderId = id;
  674. let postData = {
  675. orderId: id
  676. };
  677. this.spinShow = true;
  678. findPurchaseOrder(postData).then(res => {
  679. this.spinShow = false;
  680. if (res.status == 200) {
  681. let data = res.data;
  682. let tableArr = [];
  683. this.form.dgbh = data.orderCode;
  684. this.form.bt = data.title;
  685. this.form.glqy = data.areaId + "," + data.areaName;
  686. this.form.glxm = data.projectId + "," + data.projectName;
  687. // this.form.djlx = data.type;
  688. this.form.cgr = data.purchaserName;
  689. this.form.cgrlxfs = data.purchaserTel;
  690. this.form.xdrq = data.orderTime;
  691. this.form.jhsj = data.deliveryTime;
  692. this.form.shr = data.receivedName;
  693. this.form.shrlxfs = data.receivedTel;
  694. this.form.gys = data.gpId;
  695. this.form.gffzr = data.gpcName;
  696. this.form.gyslxdh = data.gpcPhone;
  697. this.form.spzt = data.approvalState;
  698. this.form.fptt = data.invoiceTitleCode;
  699. if (data.approvalState == "3") {
  700. this.tableColumn = [
  701. {
  702. title: "申购计划",
  703. slot: "applyRuleCode",
  704. tooltip: "true",
  705. width: 100
  706. },
  707. {
  708. title: "物料编码",
  709. key: "code",
  710. tooltip: "true",
  711. width: 100
  712. },
  713. {
  714. title: "物料分类",
  715. key: "firstClassName",
  716. tooltip: "true",
  717. width: 100
  718. },
  719. {
  720. title: "物料名称",
  721. key: "materialName",
  722. tooltip: "true",
  723. width: 200
  724. },
  725. {
  726. title: "规格型号",
  727. key: "specs",
  728. tooltip: "true",
  729. width: 100
  730. },
  731. {
  732. title: "单位",
  733. key: "unit",
  734. tooltip: "true",
  735. width: 100
  736. },
  737. {
  738. title: "计划数量",
  739. key: "amount",
  740. tooltip: "true",
  741. width: 100
  742. },
  743. {
  744. title: "已下订数量",
  745. key: "billedAmount",
  746. tooltip: "true",
  747. width: 100
  748. },
  749. {
  750. title: "累计入库数量",
  751. key: "warehousedNum",
  752. tooltip: "true",
  753. width: 120
  754. },
  755. {
  756. title: "待采购数量",
  757. key: "applySurplusNum",
  758. tooltip: "true",
  759. width: 120
  760. },
  761. {
  762. title: "采购数量",
  763. slot: "purchaseNum",
  764. tooltip: "true",
  765. width: 100
  766. },
  767. {
  768. title: "单价(元)",
  769. slot: "price",
  770. tooltip: "true",
  771. width: 100
  772. },
  773. {
  774. title: "总价(元)",
  775. slot: "totalPrice",
  776. tooltip: "true",
  777. width: 100
  778. },
  779. {
  780. title: "入库仓库",
  781. key: "storehouseName",
  782. tooltip: "true",
  783. width: 130
  784. },
  785. {
  786. title: "计划到货时间",
  787. slot: "plannedArrivalTime",
  788. tooltip: "true",
  789. width: 150
  790. },
  791. {
  792. title: "数量管控",
  793. slot: "isNumControl",
  794. tooltip: "true",
  795. width: 100
  796. },
  797. {
  798. title: "时间管控",
  799. slot: "isTimeControl",
  800. tooltip: "true",
  801. width: 100
  802. },
  803. {
  804. title: "备注",
  805. slot: "remark",
  806. tooltip: "true",
  807. width: 100
  808. },
  809. {
  810. title: "状态",
  811. slot: "isCancel",
  812. tooltip: "true",
  813. width: 100
  814. },
  815. {
  816. title: "操作",
  817. slot: "cz",
  818. tooltip: "true",
  819. width: 60
  820. }
  821. ];
  822. }
  823. this.form.sm = data.instruction;
  824. this.form.ddzt = data.orderState;
  825. this.form.gysmc = data.gpName;
  826. this.form.jhdd = data.deliveryPlace;
  827. this.requestId = data.requestId;
  828. this.form.filesList = data.attachmentList;
  829. this.orderType = "edit";
  830. for (let item in data.detailList) {
  831. tableArr.push({
  832. applyDetailId: data.detailList[item].applyDetailId,
  833. applyRuleId: data.detailList[item].applyRuleId,
  834. applyRuleCode: data.detailList[item].applyRuleCode,
  835. code: data.detailList[item].detailList[0].code,
  836. firstClassName:
  837. data.detailList[item].detailList[0].firstClassName,
  838. materialName: data.detailList[item].detailList[0].materialName,
  839. brandName: data.detailList[item].detailList[0].brandName,
  840. specs: data.detailList[item].detailList[0].specs,
  841. unit: data.detailList[item].detailList[0].unit,
  842. isCancel: data.detailList[item].isCancel,
  843. id: data.detailList[item].id,
  844. amount: Number(data.detailList[item].detailList[0].amount),
  845. billedAmount: Number(
  846. data.detailList[item].detailList[0].billedAmount
  847. ).toFixed(2),
  848. inventory: Number(
  849. data.detailList[item].detailList[0].inventory
  850. ).toFixed(2),
  851. storehouseName:
  852. data.detailList[item].detailList[0].storehouseName,
  853. price: data.detailList[item].price,
  854. totalPrice: 0,
  855. purchaseNum: data.detailList[item].purchaseNum,
  856. plannedArrivalTime: data.detailList[item].plannedArrivalTime,
  857. isNumControl: data.detailList[item].isNumControl,
  858. isTimeControl: data.detailList[item].isTimeControl,
  859. applySurplusNum: Number(
  860. data.detailList[item].applySurplusNum
  861. ).toFixed(2),
  862. warehousedNum: Number(
  863. data.detailList[item].warehousedNum
  864. ).toFixed(2),
  865. remark: data.detailList[item].remark
  866. });
  867. console.log(tableArr);
  868. this.tableData = tableArr;
  869. }
  870. let postData = {
  871. areaId: data.areaId,
  872. userId: localStorage.user_id
  873. };
  874. getProjectList(postData).then(res => {
  875. this.glxmList = res.items;
  876. });
  877. } else {
  878. this.$Message.error(res.message);
  879. }
  880. });
  881. },
  882. //审批记录跳转
  883. toSpjl() {
  884. let link = `http://gdoa1.kingser.com:88/westvalley/PSWorkflow/PSWorkflowDecode.jsp?loginmsg=bG9naW5pZD1wbXMmdXNlcnBhc3N3b3JkPVBBYjEyMzQ1Nio=&requestid=${this.requestId}`;
  885. window.open(link);
  886. },
  887. //编辑采购订单
  888. editCgdd() {
  889. for (let i in this.tableData) {
  890. if (this.tableData[i].purchaseNum <= 0) {
  891. this.$Message.error("计划明细申购数量不能小于或等于0!");
  892. return false;
  893. }
  894. if (this.tableData[i].price <= 0) {
  895. this.$Message.error("计划明细单价不能小于或等于0!");
  896. return false;
  897. }
  898. }
  899. let gpName = this.gysList.filter(a => a.gpId == this.form.gys);
  900. for (let i in this.tableData) {
  901. this.tableData[i].price = Number(this.tableData[i].price);
  902. this.tableData[i].purchaseNum = Number(this.tableData[i].purchaseNum);
  903. this.tableData[i].totalPrice = Number(
  904. this.tableData[i].price * this.tableData[i].purchaseNum
  905. );
  906. }
  907. return new Promise((resolve, reject) => {
  908. let postData = {
  909. areaId: this.form.glqy.split(",")[0],
  910. areaName: this.form.glqy.split(",")[1],
  911. projectId: this.form.glxm.split(",")[0],
  912. projectName: this.form.glxm.split(",")[1],
  913. purchaserId: localStorage.user_id,
  914. purchaserName: localStorage.user_name,
  915. purchaserTel: this.form.cgrlxfs,
  916. receivedName: this.form.shr,
  917. receivedTel: this.form.shrlxfs,
  918. orderTime: this.form.xdrq,
  919. invoiceTitleCode: this.form.fptt,
  920. // deliveryStartTime: this.form.jhsj[0],
  921. // deliveryEndTime: this.form.jhsj[1],
  922. deliveryTime: this.form.jhsj,
  923. deliveryPlace: this.form.jhdd,
  924. // type: this.form.djlx,
  925. instruction: this.form.sm,
  926. attachmentList: this.form.filesList,
  927. gpId: this.form.gys, //供应商ID
  928. gpNmae: gpName.length ? gpName[0].gpName : "", //供应商Name
  929. orderId: this.orderId,
  930. // deleteId: this.deleteIds.join(","),
  931. attachmentList: this.form.filesList,
  932. detailList: this.tableData
  933. };
  934. this.spinShow = true;
  935. this.tableLoading = true;
  936. editPurchaseOrder(postData).then(res => {
  937. this.spinShow = false;
  938. this.tableLoading = false;
  939. if (res.status == 200) {
  940. this.$Message.success("编辑采购订单成功!");
  941. this.getCgddXq(this.orderId);
  942. resolve();
  943. } else {
  944. this.$Message.error(res.message);
  945. reject();
  946. }
  947. });
  948. });
  949. },
  950. submitCgdd() {
  951. this.editCgdd().then(() => {
  952. let gpName = this.gysList.filter(a => a.gpId == this.form.gys);
  953. let postData = {
  954. orderId: this.orderId
  955. };
  956. submitPurchaseOrder(postData).then(res => {
  957. if (res.status == 200) {
  958. this.$Message.success("提交采购订单成功!");
  959. this.form.spzt = "2";
  960. } else {
  961. this.$Message.error(res.message);
  962. }
  963. });
  964. });
  965. },
  966. //新增采购订单
  967. addCgdd() {
  968. let mustArr = [
  969. "glqy",
  970. "glxm",
  971. "xdrq",
  972. "jhsj",
  973. "cgrlxfs",
  974. "shr",
  975. "shrlxfs",
  976. "gys",
  977. "fptt"
  978. ];
  979. for (let i in mustArr) {
  980. if (mustArr[i] == "cgrlxfs") {
  981. if (!phoneFun(this.form[mustArr[i]])) {
  982. this.$Message.error("请填写正确的采购人联系方式!");
  983. return false;
  984. }
  985. }
  986. if (mustArr[i] == "shrlxfs") {
  987. if (!phoneFun(this.form[mustArr[i]])) {
  988. this.$Message.error("请填写正确的收货人联系方式!");
  989. return false;
  990. }
  991. }
  992. if (!this.form[mustArr[i]]) {
  993. this.$Message.error("请将信息填写完整!");
  994. return false;
  995. }
  996. if (this.form[mustArr[i]] == "" || this.form[mustArr[i]].length == 0) {
  997. this.$Message.error("请将信息填写完整!");
  998. return false;
  999. }
  1000. }
  1001. if (!this.gysGo) {
  1002. this.$Message.error(
  1003. "供应商信息不完整,请完善供应商信息或选择其他供应商!"
  1004. );
  1005. return false;
  1006. }
  1007. if (this.orderType == "edit") {
  1008. this.editCgdd();
  1009. return false;
  1010. }
  1011. let gpName = this.gysList.filter(a => a.gpId == this.form.gys);
  1012. let postData = {
  1013. areaId: this.form.glqy.split(",")[0],
  1014. areaName: this.form.glqy.split(",")[1],
  1015. projectId: this.form.glxm.split(",")[0],
  1016. projectName: this.form.glxm.split(",")[1],
  1017. purchaserId: localStorage.user_id,
  1018. purchaserName: localStorage.user_name,
  1019. purchaserTel: this.form.cgrlxfs,
  1020. receivedName: this.form.shr,
  1021. receivedTel: this.form.shrlxfs,
  1022. orderTime: this.form.xdrq,
  1023. invoiceTitleCode: this.form.fptt,
  1024. // deliveryStartTime: this.form.jhsj[0],
  1025. // deliveryEndTime: this.form.jhsj[1],
  1026. deliveryTime: this.form.jhsj,
  1027. deliveryPlace: this.form.jhdd,
  1028. // type: this.form.djlx,
  1029. instruction: this.form.sm,
  1030. attachmentList: this.form.filesList,
  1031. gpId: this.form.gys, //供应商ID
  1032. gpNmae: gpName.length ? gpName[0].gpName : "" //供应商Name
  1033. };
  1034. this.spinShow = true;
  1035. addPurchaseOrder(postData).then(res => {
  1036. this.spinShow = false;
  1037. if (res.status == 200) {
  1038. this.$Message.success("新增采购订单成功!");
  1039. this.orderId = res.data.orderId;
  1040. this.form.dgbh = res.data.orderCode;
  1041. this.form.bt = res.data.title;
  1042. this.form.jhdd = res.data.deliveryPlace;
  1043. this.form.filesList = res.data.attachmentList;
  1044. this.orderType = "edit";
  1045. } else {
  1046. this.$Message.error(res.message);
  1047. }
  1048. });
  1049. },
  1050. //新增明细
  1051. mxAddShow() {
  1052. this.contentShow = false;
  1053. if (this.tableData.length > 0) {
  1054. this.$refs.mxAdd.searchForm.ck = String(this.tableData[0].storehouseId);
  1055. this.$refs.mxAdd.ckLock = true;
  1056. } else {
  1057. this.$refs.mxAdd.searchForm.ck = "";
  1058. this.$refs.mxAdd.ckLock = false;
  1059. }
  1060. this.$refs.mxAdd.gpId = this.form.gys;
  1061. this.$refs.mxAdd.orderId = this.orderId;
  1062. this.$refs.mxAdd.approvalState = this.form.spzt;
  1063. this.$refs.mxAdd.orderState = this.form.ddzt;
  1064. this.$refs.mxAdd.areaId = this.form.glqy;
  1065. this.$refs.mxAdd.projectId = this.form.glxm;
  1066. this.$refs.mxAdd.getTableData();
  1067. this.$refs.mxAdd.getCk();
  1068. },
  1069. //列表方法
  1070. getTableData() {
  1071. this.spinShow = false;
  1072. },
  1073. //删除采购明细
  1074. deleteRow(index) {
  1075. if (this.deleteIds.indexOf(this.tableData[index].applyDetailId) == -1) {
  1076. this.deleteIds.push(this.tableData[index].applyDetailId);
  1077. }
  1078. this.tableData.splice(index, 1);
  1079. },
  1080. //取消采购明细
  1081. cancelRow(row, index) {
  1082. if (this.form.cgr != localStorage.user_name) {
  1083. this.$Message.error(
  1084. "当前登录人与该订单采购人非同一人,无法取消该明细!"
  1085. );
  1086. }
  1087. editPurchaseOrderDetailState(row.id).then(res => {
  1088. if (res.status == 200) {
  1089. this.$Message.success("取消采购订单明细成功!");
  1090. this.tableData[index].isCancel = 1;
  1091. } else {
  1092. this.$Message.error(res.message);
  1093. }
  1094. });
  1095. },
  1096. //批量添加
  1097. plAdd(list) {
  1098. console.log(list);
  1099. for (let item in list) {
  1100. if (this.deleteIds.indexOf(list[item].applyDetailId) != -1) {
  1101. this.deleteIds.splice(
  1102. this.deleteIds.indexOf(list[item].applyDetailId),
  1103. 1
  1104. );
  1105. }
  1106. if (
  1107. this.tableData.filter(
  1108. a => a.applyDetailId == list[item].applyDetailId
  1109. ).length > 0
  1110. ) {
  1111. } else {
  1112. this.tableData.push(list[item]);
  1113. }
  1114. }
  1115. },
  1116. printRow() {
  1117. this.printShow = true;
  1118. this.$refs.print.getData(this.orderId);
  1119. },
  1120. tableOnSelect(selection, row) {},
  1121. //取消、返回
  1122. cancel() {
  1123. this.form.dgbh = "";
  1124. this.form.bt = "";
  1125. this.form.glqy = "";
  1126. this.form.glxm = "";
  1127. this.form.djlx = "";
  1128. this.form.cgr = "";
  1129. this.form.cgrlxfs = "";
  1130. this.form.xdrq = "";
  1131. this.form.jhsj = "";
  1132. this.form.jhdd = "";
  1133. this.form.shr = "";
  1134. this.form.shrlxfs = "";
  1135. this.form.gys = "";
  1136. this.form.gffzr = "";
  1137. this.form.gyslxdh = "";
  1138. this.form.sm = "";
  1139. this.form.filesList = [];
  1140. this.form.ddzt = 1;
  1141. this.form.spzt = 1;
  1142. this.tableData = [];
  1143. this.deleteIds = [];
  1144. this.orderType = "add";
  1145. this.form.fptt = "";
  1146. this.spinShow = false;
  1147. this.tableColumn = [
  1148. {
  1149. title: "申购计划",
  1150. slot: "applyRuleCode",
  1151. tooltip: "true",
  1152. width: 100
  1153. },
  1154. {
  1155. title: "物料编码",
  1156. key: "code",
  1157. tooltip: "true",
  1158. width: 100
  1159. },
  1160. {
  1161. title: "物料分类",
  1162. key: "firstClassName",
  1163. tooltip: "true",
  1164. width: 100
  1165. },
  1166. {
  1167. title: "物料名称",
  1168. key: "materialName",
  1169. tooltip: "true",
  1170. width: 200
  1171. },
  1172. {
  1173. title: "规格型号",
  1174. key: "specs",
  1175. tooltip: "true",
  1176. width: 100
  1177. },
  1178. {
  1179. title: "单位",
  1180. key: "unit",
  1181. tooltip: "true",
  1182. width: 100
  1183. },
  1184. {
  1185. title: "计划数量",
  1186. key: "amount",
  1187. tooltip: "true",
  1188. width: 100
  1189. },
  1190. {
  1191. title: "已下订数量",
  1192. key: "billedAmount",
  1193. tooltip: "true",
  1194. width: 100
  1195. },
  1196. {
  1197. title: "累计入库数量",
  1198. key: "warehousedNum",
  1199. tooltip: "true",
  1200. width: 120
  1201. },
  1202. {
  1203. title: "待采购数量",
  1204. key: "applySurplusNum",
  1205. tooltip: "true",
  1206. width: 120
  1207. },
  1208. {
  1209. title: "采购数量",
  1210. slot: "purchaseNum",
  1211. tooltip: "true",
  1212. width: 100
  1213. },
  1214. {
  1215. title: "单价(元)",
  1216. slot: "price",
  1217. tooltip: "true",
  1218. width: 100
  1219. },
  1220. {
  1221. title: "总价(元)",
  1222. slot: "totalPrice",
  1223. tooltip: "true",
  1224. width: 100
  1225. },
  1226. {
  1227. title: "入库仓库",
  1228. key: "storehouseName",
  1229. tooltip: "true",
  1230. width: 130
  1231. },
  1232. {
  1233. title: "计划到货时间",
  1234. slot: "plannedArrivalTime",
  1235. tooltip: "true",
  1236. width: 150
  1237. },
  1238. {
  1239. title: "数量管控",
  1240. slot: "isNumControl",
  1241. tooltip: "true",
  1242. width: 100
  1243. },
  1244. {
  1245. title: "时间管控",
  1246. slot: "isTimeControl",
  1247. tooltip: "true",
  1248. width: 100
  1249. },
  1250. {
  1251. title: "备注",
  1252. slot: "remark",
  1253. tooltip: "true",
  1254. width: 100
  1255. },
  1256. {
  1257. title: "操作",
  1258. slot: "cz",
  1259. tooltip: "true",
  1260. width: 60
  1261. }
  1262. ];
  1263. this.$emit("return");
  1264. }
  1265. },
  1266. watch: {
  1267. tableData: {
  1268. handler(val, name) {
  1269. let total = 0;
  1270. let arr = [];
  1271. let str = "";
  1272. for (let item in val) {
  1273. if (val[item].isCancel) {
  1274. } else {
  1275. total += val[item].price * val[item].purchaseNum;
  1276. }
  1277. arr.push(val[item].applyRuleCode);
  1278. }
  1279. let set = new Set(arr);
  1280. this.form.totalPrice = total.toFixed(2);
  1281. this.form.glsgjh = [...set].join(",");
  1282. },
  1283. deep: true
  1284. }
  1285. }
  1286. };
  1287. </script>
  1288. <style lang="scss" scoped>
  1289. .mustSpan {
  1290. color: red;
  1291. margin-left: 2px;
  1292. }
  1293. button {
  1294. min-width: 80px;
  1295. }
  1296. .uplCont {
  1297. border-left: 1px solid #e4e4e4;
  1298. .upl {
  1299. flex: auto;
  1300. border-right: 1px solid #e4e4e4;
  1301. &:nth-child(1),
  1302. &:nth-child(4) {
  1303. background: #f8f9fb;
  1304. display: flex;
  1305. align-items: center;
  1306. justify-content: center;
  1307. }
  1308. &:nth-child(5) {
  1309. display: flex;
  1310. align-items: center;
  1311. justify-content: center;
  1312. }
  1313. }
  1314. .uplf {
  1315. display: flex;
  1316. align-items: center;
  1317. justify-content: center;
  1318. min-height: 80px;
  1319. }
  1320. }
  1321. .mainCont .tables {
  1322. min-height: 50px;
  1323. border-right: 1px solid #e4e4e4;
  1324. border-bottom: 1px solid #e4e4e4;
  1325. display: flex;
  1326. align-items: center;
  1327. justify-content: center;
  1328. word-break: break-all;
  1329. &:nth-child(2n + 1) {
  1330. background: #f8f9fb;
  1331. }
  1332. }
  1333. .mainCont {
  1334. border-left: 1px solid #e4e4e4;
  1335. border-top: 1px solid #e4e4e4;
  1336. }
  1337. ivu-card-head-inner,
  1338. .ivu-card-head p {
  1339. display: inline-block;
  1340. width: 100%;
  1341. height: 20px;
  1342. line-height: 20px;
  1343. font-size: 14px;
  1344. color: #17233d;
  1345. font-weight: 700;
  1346. overflow: hidden;
  1347. text-overflow: ellipsis;
  1348. white-space: nowrap;
  1349. font-weight: normal;
  1350. }
  1351. </style>