edit.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172
  1. <template>
  2. <div>
  3. <Toptitle :title="$route.query.type == 1 ? '新增出库单' :$route.query.type == 2 ?'出库单详情':'编辑出库单'">
  4. <slot name="titleButton">
  5. <Button
  6. @click="handleReference(8, 1)"
  7. type="primary"
  8. ghost
  9. style="margin-right: 10px"
  10. :disabled='btn1_disable'
  11. v-show="!isCheck"
  12. >参照入库单</Button
  13. >
  14. <Button
  15. @click="handleReference(9, 4)"
  16. :disabled="btn2_disable"
  17. type="primary"
  18. ghost
  19. style="margin-right: 10px"
  20. v-show="!isCheck"
  21. >参照派工单</Button
  22. >
  23. <!-- <Button @click="handleReference(4)"
  24. type="primary"
  25. ghost
  26. style="margin-right:10px;">参照质检单</Button> -->
  27. <Button @click="goBack" type="primary" ghost style="margin-right: 10px"
  28. >返回</Button
  29. >
  30. <Button
  31. @click="postData"
  32. type="primary"
  33. ghost
  34. style="margin-right: 10px"
  35. v-show="!isCheck"
  36. >确定</Button
  37. >
  38. </slot>
  39. </Toptitle>
  40. <div class="content_topform">
  41. <Form :label-width="90" :model="searchData">
  42. <FormItem label="项目名称:">
  43. <Input
  44. type="text"
  45. size="small"
  46. v-model="searchData.residential_name"
  47. style="width: 200px; margin-top: 6px"
  48. placeholder="项目名称"
  49. v-show="!isCheck"
  50. >
  51. <span
  52. slot="append"
  53. style="cursor: pointer"
  54. @click="showProjectModal = true"
  55. >选择</span
  56. >
  57. </Input>
  58. <span v-show="isCheck">{{searchData.residential_name}}</span>
  59. </FormItem>
  60. <FormItem label="供应商名称:">
  61. <Input
  62. type="text"
  63. size="small"
  64. v-model="searchData.title"
  65. style="width: 200px; margin-top: 6px"
  66. v-show="!isCheck"
  67. placeholder="供应商名称"
  68. >
  69. <span
  70. slot="append"
  71. style="cursor: pointer"
  72. @click="showSupplierModal = true"
  73. >选择</span
  74. >
  75. </Input>
  76. <span v-show="isCheck">{{searchData.title}}</span>
  77. </FormItem>
  78. <FormItem label='仓库'>
  79. <Select v-model="searchData.warehouse_type"
  80. size="small"
  81. clearable
  82. filterable
  83. v-show="!isCheck"
  84. label-in-value
  85. style="width: 200px">
  86. <Option v-for="(sitem) in warehouse_type"
  87. :key="sitem.id"
  88. :label="sitem.title"
  89. :value="sitem.id">
  90. </Option>
  91. </Select>
  92. </FormItem>
  93. <FormItem label="单据号:">
  94. <Input
  95. type="text"
  96. size="small"
  97. readonly
  98. v-model="searchData.order_out_no"
  99. v-show="!isCheck"
  100. style="width: 200px"
  101. placeholder="自动生成"
  102. />
  103. <span v-show="isCheck">{{searchData.order_out_no}}</span>
  104. </FormItem>
  105. <!-- <FormItem label="制单人:">
  106. <Input type="text"
  107. size="small"
  108. v-model="searchData.nickname"
  109. style="width: 200px"
  110. placeholder="制单人" />
  111. </FormItem> -->
  112. <FormItem label='出库类型'>
  113. <Select v-model="searchData.type_id"
  114. size="small"
  115. clearable
  116. v-show="!isCheck"
  117. style="width: 200px">
  118. <Option v-for="(sitem) in out_stock_type"
  119. :key="sitem.id"
  120. :label="sitem.title"
  121. :value="sitem.id">
  122. </Option>
  123. </Select>
  124. </FormItem>
  125. <FormItem label="制单日期:">
  126. <DatePicker
  127. type="date"
  128. size="small"
  129. style="width: 200px"
  130. placeholder="年/月/日"
  131. v-show="!isCheck"
  132. :value="func.replaceDate(searchData.crt_time)"
  133. ></DatePicker>
  134. <span v-show="isCheck">{{func.replaceDate(searchData.crt_time)}}</span>
  135. </FormItem>
  136. <FormItem label="备注:">
  137. <Input
  138. type="textarea"
  139. size="small"
  140. v-model="searchData.remark"
  141. v-show="!isCheck"
  142. style="width: 200px"
  143. placeholder="备注"
  144. />
  145. <span v-show="isCheck">{{searchData.remark}}</span>
  146. </FormItem>
  147. </Form>
  148. </div>
  149. <div class="content_table">
  150. <div class="content_table_btn">
  151. <div>
  152. <span>出库清单</span>
  153. <Button
  154. @click="showModal = true"
  155. type="primary"
  156. size="small"
  157. style="margin-left: 10px"
  158. :disabled="btn_disable"
  159. v-show="!isCheck"
  160. >选择物料</Button
  161. >
  162. </div>
  163. <div class="content_table_btn_right"></div>
  164. </div>
  165. <Table :columns="$route.query.type == 2?tableColumns_detailed:tableColumns" border :data="tableData" show-summary :summary-method="handleSummary">
  166. <template slot="setSlot" slot-scope="{ row, index }">
  167. <a
  168. style="margin: 0 5px"
  169. :disabled="row.state == 0"
  170. @click="handleSet(4, row, index)"
  171. >删除</a
  172. >
  173. </template>
  174. </Table>
  175. </div>
  176. <Modal
  177. v-model="showModal"
  178. title="选择物料"
  179. width="80"
  180. @on-ok="handleSelect"
  181. @on-cancel="showModal = false"
  182. >
  183. <div class="modal_content">
  184. <div class="modal_content_left">
  185. <Tree
  186. :data="modalData.treeData"
  187. children-key="list"
  188. style="width: 100%"
  189. @on-select-change="handleTreeSlect"
  190. class="demo-tree-render"
  191. ></Tree>
  192. </div>
  193. <div class="modal_content_center">
  194. <div class="modal_content_center_top">
  195. <div>
  196. <span>物料名称:</span>
  197. <Input
  198. type="text"
  199. v-model="modalData.title"
  200. placeholder="请输入物料名称"
  201. />
  202. </div>
  203. <Button @click="initModal()" type="primary" style="margin: 0 10px"
  204. >搜索</Button
  205. >
  206. </div>
  207. <div class="modal_content_center_body">
  208. <Table
  209. :columns="modalTableColumns"
  210. height="520"
  211. border
  212. @on-select="handleSelection"
  213. :loading="modalTableLoading"
  214. :data="modalData.tableData"
  215. >
  216. </Table>
  217. <div class="modal_content_center_footer">
  218. <Page
  219. :page-size-opts="[10, 20, 30, 40, 100]"
  220. @on-page-size-change="changeModalSize"
  221. @on-change="changeModalPage"
  222. :current="modal_page_index"
  223. show-total
  224. :total="modal_total"
  225. show-sizer
  226. :page-size="modal_page_size"
  227. />
  228. </div>
  229. </div>
  230. </div>
  231. <div class="modal_content_right">
  232. <span>已选</span>
  233. <Table
  234. :columns="selectedColumns"
  235. max-height="500"
  236. border
  237. :data="modalData.selectedData"
  238. >
  239. <template slot="selectedSetSlot" slot-scope="{ row, index }">
  240. <a
  241. style="margin: 0 5px; color: red"
  242. @click="handleSelectedDele(row, index)"
  243. >删除</a
  244. >
  245. </template>
  246. </Table>
  247. </div>
  248. </div>
  249. </Modal>
  250. <Modal
  251. v-model="showProjectModal"
  252. title="选择项目"
  253. width="80"
  254. @on-ok="handleProjectSelect"
  255. @on-cancel="showProjectModal = false"
  256. >
  257. <div class="modal_content">
  258. <div class="modal_content_center">
  259. <div class="modal_content_center_top">
  260. <span>项目名称:</span>
  261. <Input
  262. type="text"
  263. v-model="modalProjectData.title"
  264. style="width: 180px"
  265. placeholder="请输入物料名称"
  266. />
  267. <Button
  268. @click="initProjectModal()"
  269. type="primary"
  270. style="margin: 0 10px"
  271. >搜索</Button
  272. >
  273. </div>
  274. <div class="modal_content_center_body">
  275. <Table
  276. :columns="modalProjectTableColumns"
  277. height="520"
  278. border
  279. :loading="modalProjectTableLoading"
  280. :data="modalProjectData.tableData"
  281. >
  282. <template slot="basicTypeSet" slot-scope="{ row }">
  283. <div>
  284. <span
  285. v-for="item in warningList"
  286. :key="item.id"
  287. :style="{ color: item.color }"
  288. v-show="item.id == row.warning_state"
  289. >{{ item.title }}</span
  290. >
  291. </div>
  292. </template>
  293. </Table>
  294. <div class="modal_content_center_footer">
  295. <Page
  296. :page-size-opts="[10, 20, 30, 40, 100]"
  297. @on-page-size-change="changeProjectModalSize"
  298. @on-change="changeProjectModalPage"
  299. :current="modal_project_page_index"
  300. show-total
  301. :total="modal_project_total"
  302. show-sizer
  303. :page-size="modal_project_page_size"
  304. />
  305. </div>
  306. </div>
  307. </div>
  308. </div>
  309. </Modal>
  310. <Modal
  311. v-model="showSupplierModal"
  312. title="选择供应商"
  313. width="80"
  314. @on-ok="handleSupplierSelect"
  315. @on-cancel="showSupplierModal = false"
  316. >
  317. <div class="modal_content">
  318. <div class="modal_content_left">
  319. <Tree
  320. :data="modalSupplierData.treeData"
  321. children-key="sub"
  322. style="width: 100%"
  323. @on-select-change="handleSupplierTreeSlect"
  324. class="demo-tree-render"
  325. ></Tree>
  326. </div>
  327. <div class="modal_content_center">
  328. <div class="modal_content_center_top">
  329. <span>供应商名称:</span>
  330. <Input
  331. type="text"
  332. v-model="modalSupplierData.title"
  333. style="width: 180px"
  334. placeholder="请输入供应商名称"
  335. />
  336. <Button
  337. @click="initSupplierModal(modalSupplierData)"
  338. type="primary"
  339. style="margin: 0 10px"
  340. >搜索</Button
  341. >
  342. </div>
  343. <div class="modal_content_center_body">
  344. <Table
  345. :columns="modalSupplierTableColumns"
  346. height="520"
  347. border
  348. :loading="modalSupplierTableLoading"
  349. :data="modalSupplierData.tableData"
  350. >
  351. </Table>
  352. <div class="modal_content_center_footer">
  353. <Page
  354. :page-size-opts="[10, 20, 30, 40, 100]"
  355. @on-page-size-change="changeSupplierModalSize"
  356. @on-change="changeSupplierModalPage"
  357. :current="modal_supplier_page_index"
  358. show-total
  359. :total="modal_supplier_total"
  360. show-sizer
  361. :page-size="modal_supplier_page_size"
  362. />
  363. </div>
  364. </div>
  365. </div>
  366. </div>
  367. </Modal>
  368. </div>
  369. </template>
  370. <script>
  371. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  372. // 例如:import 《组件名称》 from '《组件路径》';
  373. export default {
  374. name: "",
  375. components: {},
  376. props: {},
  377. // import引入的组件需要注入到对象中才能使用
  378. data() {
  379. // 这里存放数据
  380. return {
  381. out_stock_type:[{id:0,title:'未出库'},
  382. {id:1,title:'已出库'}],
  383. warehouse_type:[],
  384. isCheck:false,
  385. is_refer:'',
  386. btn_disable:false,
  387. btn1_disable:false,
  388. btn2_disable:false,
  389. fax_modify: "",
  390. searchData: {
  391. residential_name: "",
  392. warehouse_type:''
  393. },
  394. modalProjectData: {
  395. title: "",
  396. tableData: [{}],
  397. },
  398. modalSupplierData: {
  399. title: "",
  400. code: "",
  401. treeData: [
  402. {
  403. title: "供应商分类",
  404. expand: true,
  405. sub: [],
  406. render: (h, { root, node, data }) => {
  407. return h(
  408. "span",
  409. {
  410. style: {
  411. display: "inline-block",
  412. width: "100%",
  413. },
  414. },
  415. [
  416. h("span", [
  417. h("Icon", {
  418. props: {
  419. type: "ios-folder-outline",
  420. },
  421. style: {
  422. marginRight: "8px",
  423. },
  424. }),
  425. h("span", data.title),
  426. ]),
  427. h("span", {
  428. style: {
  429. display: "inline-block",
  430. // float: 'right',
  431. marginRight: "32px",
  432. },
  433. }),
  434. ]
  435. );
  436. },
  437. },
  438. ],
  439. tableData: [{}],
  440. },
  441. tableColumns_detailed:[{
  442. title: "物料分类",
  443. key: "type_title",
  444. align: "center",
  445. minWidth: 140,
  446. },
  447. { title: "物料名称", key: "title", align: "center", minWidth: 140 },
  448. {
  449. title: "物料规格",
  450. key: "",
  451. align: "center",
  452. minWidth: 140,
  453. render: (h, params) => {
  454. const { row } = params;
  455. let text = `${row.long ? row.long : 0}*${
  456. row.width ? row.width : 0
  457. }*${row.high ? row.high : 0}`;
  458. return h("span", {}, text);
  459. },
  460. },
  461. { title: "计量单位", key: "unit", align: "center", minWidth: 100 },
  462. {
  463. title: "出库数量",
  464. key: "num",
  465. align: "center",
  466. minWidth: 120,
  467. render: (h, params) => {
  468. const { row, index } = params;
  469. const currentRow = JSON.parse(
  470. JSON.stringify(this.tableData[index])
  471. );
  472. return h("span", {},currentRow.num);
  473. },
  474. }],
  475. tableColumns: [
  476. {
  477. title: "物料分类",
  478. key: "type_title",
  479. align: "center",
  480. minWidth: 140,
  481. },
  482. { title: "物料名称", key: "title", align: "center", minWidth: 140 },
  483. {
  484. title: "物料规格",
  485. key: "",
  486. align: "center",
  487. minWidth: 140,
  488. render: (h, params) => {
  489. const { row } = params;
  490. let text = `${row.long ? row.long : 0}*${
  491. row.width ? row.width : 0
  492. }*${row.high ? row.high : 0}`;
  493. return h("span", {}, text);
  494. },
  495. },
  496. { title: "计量单位", key: "unit", align: "center", minWidth: 100 },
  497. {
  498. title: "数量",
  499. key: "num",
  500. align: "center",
  501. minWidth: 120,
  502. render: (h, params) => {
  503. const { row, index } = params;
  504. const currentRow = JSON.parse(
  505. JSON.stringify(this.tableData[index])
  506. );
  507. return h("Input", {
  508. props: {
  509. value: currentRow.num,
  510. type: "text",
  511. },
  512. on: {
  513. "on-change": (e) => {
  514. currentRow.num = e.target.value;
  515. // currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
  516. // currentRow.no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
  517. // currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
  518. this.tableData.splice(index, 1, currentRow);
  519. },
  520. },
  521. });
  522. },
  523. },
  524. {
  525. title: "单价",
  526. key: "total_price",
  527. align: "center",
  528. minWidth: 120,
  529. render: (h, params) => {
  530. const { row, index } = params;
  531. const currentRow = JSON.parse(
  532. JSON.stringify(this.tableData[index])
  533. );
  534. return this.$route.query.type == 2
  535. ? h("span", {}, currentRow.total_price)
  536. : h("Input", {
  537. props: {
  538. value: currentRow.total_price,
  539. type: "text",
  540. },
  541. on: {
  542. "on-change": (e) => {
  543. currentRow.total_price = e.target.value;
  544. this.tableData.splice(index, 1, currentRow);
  545. },
  546. },
  547. });
  548. },
  549. },
  550. {
  551. title: "金额", key: "total", align: "center", minWidth: 100,
  552. render: (h, params) => {
  553. const { row, index } = params;
  554. const currentRow = JSON.parse(
  555. JSON.stringify(this.tableData[index])
  556. );
  557. return h("span", {},currentRow.total_price&&currentRow.num?currentRow.total_price*currentRow.num:0)
  558. }
  559. },
  560. {
  561. title: "操作",
  562. key: "code",
  563. align: "center",
  564. minWidth: 100,
  565. slot: "setSlot",
  566. },
  567. ],
  568. tableData: [],
  569. showModal: false,
  570. showProjectModal: false,
  571. showSupplierModal: false,
  572. modalTableLoading: false,
  573. modalProjectTableLoading: false,
  574. modalSupplierTableLoading: false,
  575. modal_project_page_index: 1,
  576. modal_project_page_size: 10,
  577. modal_project_total: 0,
  578. modal_supplier_page_index: 1,
  579. modal_supplier_page_size: 10,
  580. modal_supplier_total: 0,
  581. currentChoose: {},
  582. modalProjectTableColumns: [
  583. {
  584. title: "选择",
  585. key: "",
  586. align: "center",
  587. minWidth: 60,
  588. render: (h, params) => {
  589. let id = params.row.id;
  590. let flag = false;
  591. if (this.currentChoose.id == id) {
  592. flag = true;
  593. } else {
  594. flag = false;
  595. }
  596. let self = this;
  597. return h("div", [
  598. h("Radio", {
  599. props: {
  600. value: flag,
  601. },
  602. on: {
  603. "on-change": () => {
  604. self.currentChoose = params.row;
  605. },
  606. },
  607. }),
  608. ]);
  609. },
  610. },
  611. {
  612. title: "项目名称",
  613. key: "residential_name",
  614. align: "center",
  615. minWidth: 100,
  616. },
  617. {
  618. title: "紧急程度",
  619. align: "center",
  620. key: "warning_state",
  621. minWidth: 80,
  622. slot: "basicTypeSet",
  623. },
  624. {
  625. title: "创建时间",
  626. key: "crt_time",
  627. align: "center",
  628. minWidth: 110,
  629. render: (h, params) => {
  630. const { row } = params;
  631. return h("span", {}, this.func.replaceDate(row.crt_time));
  632. },
  633. },
  634. ],
  635. modalSupplierTableColumns: [
  636. {
  637. title: "选择",
  638. key: "",
  639. align: "center",
  640. minWidth: 60,
  641. render: (h, params) => {
  642. let id = params.row.id;
  643. let flag = false;
  644. if (this.currentChoose.id == id) {
  645. flag = true;
  646. } else {
  647. flag = false;
  648. }
  649. let self = this;
  650. return h("div", [
  651. h("Radio", {
  652. props: {
  653. value: flag,
  654. },
  655. on: {
  656. "on-change": () => {
  657. self.currentChoose = params.row;
  658. },
  659. },
  660. }),
  661. ]);
  662. },
  663. },
  664. { title: "供应商编码", key: "code", align: "center", minWidth: 100 },
  665. { title: "供应商名称", key: "title", align: "center", minWidth: 80 },
  666. { title: "负责人", key: "contact", align: "center", minWidth: 110 },
  667. { title: "联系方式", key: "mobile", align: "center", minWidth: 110 },
  668. ],
  669. modalData: {
  670. title: "",
  671. tableData: [{}],
  672. selectedData: [],
  673. treeData: [
  674. {
  675. title: "物料分类",
  676. expand: true,
  677. list: [],
  678. render: (h, { root, node, data }) => {
  679. return h(
  680. "span",
  681. {
  682. style: {
  683. display: "inline-block",
  684. width: "100%",
  685. },
  686. },
  687. [
  688. h("span", [
  689. h("Icon", {
  690. props: {
  691. type: "ios-folder-outline",
  692. },
  693. style: {
  694. marginRight: "8px",
  695. },
  696. }),
  697. h("span", data.title),
  698. ]),
  699. h("span", {
  700. style: {
  701. display: "inline-block",
  702. // float: 'right',
  703. marginRight: "32px",
  704. },
  705. }),
  706. ]
  707. );
  708. },
  709. },
  710. ],
  711. },
  712. selectedColumns: [
  713. { title: "物料名称", key: "title", align: "center", minWidth: 110 },
  714. {
  715. title: "操作",
  716. key: "title",
  717. align: "center",
  718. minWidth: 90,
  719. slot: "selectedSetSlot",
  720. },
  721. ],
  722. modal_page_index: 1,
  723. modal_page_size: 10,
  724. modal_total: 0,
  725. modalTableColumns: [
  726. { title: "全选", type: "selection", align: "center", minWidth: 60 },
  727. { title: "物料名称", key: "title", align: "center", minWidth: 110 },
  728. { title: "物料规格", key: "model", align: "center", minWidth: 110 },
  729. { title: "计量单位", key: "unit", align: "center", minWidth: 110 },
  730. ],
  731. warningList: [],
  732. };
  733. },
  734. // 生命周期 - 创建完成(可以访问当前this实例)
  735. created() {
  736. this.$route.query.type == 2 ? this.isCheck = true : this.isCheck = false
  737. // 获取基础物料类型
  738. this.axios({ method: "get", url: "/api/basics_material_index_level" })
  739. .then((res) => {
  740. this.modalData.treeData[0].list = res.data;
  741. })
  742. .catch((err) => {});
  743. //获取仓库列表
  744. this.axios({method:'get',url:'/api/warehouse_type'}).then((res)=>{
  745. this.warehouse_type = res.data;
  746. })
  747. // 获取供应商列表
  748. this.axios({ method: "get", url: "/api/supply_list" })
  749. .then((res) => {
  750. this.suppliersList = res.data.data;
  751. })
  752. .catch((err) => {});
  753. // 获取供应商分类
  754. this.axios({ method: "get", url: "/api/basic_supply_list" })
  755. .then((res) => {
  756. this.modalSupplierData.treeData[0].sub = res.data;
  757. })
  758. .catch((err) => {});
  759. // 获取项目列表
  760. this.axios({ method: "get", url: "/api/order_index" })
  761. .then((res) => {
  762. this.modalProjectData.tableData = res.data.data;
  763. this.modal_project_total = res.data.total;
  764. })
  765. .catch((err) => {});
  766. // 获取紧急程度
  767. this.axios.get("/api/warning_list").then((res) => {
  768. this.warningList = res.data.data;
  769. });
  770. this.initModal();
  771. this.initProjectModal();
  772. this.initSupplierModal(this.modalSupplierData);
  773. },
  774. // 生命周期 - 挂载完成(可以访问DOM元素)
  775. mounted() {
  776. if (this.$route.query.order_out_no != "") {
  777. this.initData(this.$route.query.order_out_no);
  778. }
  779. },
  780. methods: {
  781. handleSummary ({ columns, data }) {
  782. const sums = {};
  783. columns.forEach((column, index) => {
  784. const key = column.key;
  785. if (index === 0) {
  786. sums[key] = {
  787. key,
  788. value: '合计'
  789. };
  790. return;
  791. }
  792. let val = data;
  793. for(let i in val){
  794. val[i].total = val[i].total_price*val[i].num;
  795. }
  796. const values = val.map(item => Number(item[key]));
  797. if (index === 6) {
  798. const v = values.reduce((prev, curr) => {
  799. const value = Number(curr);
  800. if (!isNaN(value)) {
  801. return prev + curr;
  802. } else {
  803. return prev;
  804. }
  805. }, 0);
  806. sums[key] = {
  807. key,
  808. value: v
  809. };
  810. }else if(index===4){
  811. const v = values.reduce((prev, curr) => {
  812. const value = Number(curr);
  813. if (!isNaN(value)) {
  814. return prev + curr;
  815. } else {
  816. return prev;
  817. }
  818. }, 0);
  819. sums[key] = {
  820. key,
  821. value: v
  822. };
  823. }
  824. else {
  825. sums[key] = {
  826. key,
  827. value: ''
  828. };
  829. }
  830. });
  831. return sums;
  832. },
  833. initData(order_out_no) {
  834. this.axios({
  835. method: "get",
  836. url: "/api/warehouse_order_out_detail",
  837. params: { order_out_no },
  838. })
  839. .then((res) => {
  840. this.tableData = res.data.list;
  841. // this.tableData.forEach(element => {
  842. // element.fax = element.fax * 100
  843. // element.total_price = (1 * element.price * element.num).toFixed(2)
  844. // element.no_tax_price = (1 * element.price / (1 + 1 * element.fax / 100)).toFixed(2)
  845. // element.no_tax_amount = (1 * element.no_tax_price * element.num).toFixed(2)
  846. // element.tax_amount = (1 * element.total_price - 1 * element.no_tax_amount).toFixed(2)
  847. // });
  848. const data = JSON.parse(JSON.stringify(res.data));
  849. delete data.list;
  850. this.searchData = data;
  851. })
  852. .catch((err) => {});
  853. },
  854. postData() {
  855. this.tableData.forEach((element) => {
  856. if (element.type != 0) {
  857. this.searchData.type = 1;
  858. } else {
  859. this.searchData.type = 0;
  860. }
  861. });
  862. let obj = JSON.parse(JSON.stringify(this.searchData));
  863. obj.crt_time = parseInt(new Date(obj.crt_time).getTime() / 1000) || "";
  864. if (this.$route.query.order_out_no == "") {
  865. // 新增
  866. this.axios({
  867. method: "post",
  868. url: "/api/warehouse_order_out_add",
  869. data: {
  870. ...obj,
  871. list: this.tableData,
  872. is_refer:this.is_refer
  873. },
  874. }).then((res) => {
  875. if(res.msg !== '请选择供应商'){
  876. this.$Message.success(res.msg);
  877. this.goBack()
  878. }
  879. })
  880. .catch((err) => {});
  881. } else {
  882. // 编辑
  883. this.axios({
  884. method: "post",
  885. url: "/api/warehouse_order_out_edit",
  886. data: {
  887. order_out_no: this.$route.query.order_out_no,
  888. ...obj,
  889. list: this.tableData,
  890. is_refer:this.is_refer
  891. },
  892. })
  893. .then((res) => {
  894. this.$Message.success(res.msg);
  895. this.goBack();
  896. })
  897. .catch((err) => {});
  898. }
  899. },
  900. handleReference(type, refer_type) {
  901. let title = type == 8 ? "参照入库单" : "参照派工单";
  902. this.$reference({
  903. type,
  904. title,
  905. refer_type,
  906. then: (result, data) => {
  907. this.tableData = [...this.tableData, ...result];
  908. this.btn_disable = true
  909. this.is_refer = 1
  910. if(type === 8){
  911. this.btn2_disable = true
  912. }else{
  913. this.btn1_disable = true
  914. }
  915. },
  916. });
  917. },
  918. handleSet(type, row, index) {
  919. this.tableData.splice(index, 1);
  920. },
  921. handleSelect() {
  922. this.modalData.selectedData.forEach((element) => {
  923. element.type_title = element.title;
  924. element.type == 0;
  925. });
  926. this.tableData = [...this.tableData, ...this.modalData.selectedData];
  927. this.btn1_disable = true
  928. this.btn2_disable = true
  929. this.is_refer = 0
  930. },
  931. changeModalSize(e) {
  932. this.modal_page_size = e;
  933. this.initModal();
  934. },
  935. changeModalPage(e) {
  936. this.modal_page_index = e;
  937. this.initModal();
  938. },
  939. initModal() {
  940. this.axios({
  941. method: "get",
  942. url: "/api/material_detail_list",
  943. params: {
  944. page_index: this.modal_page_index,
  945. page_size: this.modal_page_size,
  946. title: this.modalData.title,
  947. },
  948. })
  949. .then((res) => {
  950. this.modal_total = res.data.total;
  951. this.modalData.tableData = res.data.data;
  952. this.reselection();
  953. })
  954. .catch((err) => {});
  955. },
  956. handleSelection(selection, row) {
  957. this.modalData.selectedData.push(row);
  958. },
  959. handleSelectionCancel(selection, row) {
  960. this.modalData.selectedData.forEach((element, index) => {
  961. if (element.material_detail_id == row.material_detail_id) {
  962. this.modalData.selectedData.splice(index, 1);
  963. }
  964. });
  965. },
  966. handleSelectionAll(selection) {
  967. this.modalData.selectedData =
  968. this.modalData.selectedData.concat(selection);
  969. },
  970. handleSelectionAllCancel() {
  971. this.modalData.tableData.forEach((element) => {
  972. this.modalData.selectedData = this.modalData.selectedData.filter(
  973. (x) => {
  974. return x.material_detail_id != element.material_detail_id;
  975. }
  976. );
  977. });
  978. },
  979. reselection() {
  980. this.modalData.selectedData.forEach((element) => {
  981. this.modalData.tableData.forEach((ele, idx) => {
  982. if (element.material_detail_id == ele.material_detail_id) {
  983. this.$nextTick(() => {
  984. this.$refs.modelTable.$refs.tbody.objData[idx]._isChecked = true;
  985. this.$forceUpdate();
  986. });
  987. }
  988. });
  989. });
  990. },
  991. handleTreeSlect(array, row) {
  992. row.id &&
  993. this.axios({
  994. method: "get",
  995. url: "/api/material_detail_list",
  996. params: {
  997. page_index: this.modal_page_index,
  998. page_size: this.modal_page_size,
  999. m_id: row.id,
  1000. },
  1001. })
  1002. .then((res) => {
  1003. this.modal_total = res.data.total;
  1004. this.modalData.tableData = res.data.data;
  1005. })
  1006. .catch((err) => {});
  1007. },
  1008. handleSelectedDele(row, index) {
  1009. this.modalData.selectedData.splice(index, 1);
  1010. },
  1011. goBack() {
  1012. this.$router.go(-1);
  1013. },
  1014. handleProjectSelect() {
  1015. this.searchData.residential_name = this.currentChoose.residential_name;
  1016. this.searchData.order_no = this.currentChoose.order_no;
  1017. },
  1018. handleSupplierSelect() {
  1019. this.searchData.title = this.currentChoose.title;
  1020. this.searchData.supply_id = this.currentChoose.id;
  1021. },
  1022. changeProjectModalSize(e) {
  1023. this.modal_project_page_size = e;
  1024. this.initProjectModal();
  1025. },
  1026. changeProjectModalPage(e) {
  1027. this.modal_project_page_index = e;
  1028. this.initProjectModal();
  1029. },
  1030. initProjectModal() {
  1031. this.axios({
  1032. method: "get",
  1033. url: "/api/order_index",
  1034. params: {
  1035. page_index: this.modal_project_page_index,
  1036. page_size: this.modal_project_page_size,
  1037. title: this.modalProjectData.title,
  1038. },
  1039. })
  1040. .then((res) => {
  1041. this.modal_project_total = res.data.total;
  1042. this.modalProjectData.tableData = res.data.data;
  1043. })
  1044. .catch((err) => {});
  1045. },
  1046. changeSupplierModalSize(e) {
  1047. this.modal_supplier_page_size = e;
  1048. this.initSupplierModal(this.modalSupplierData);
  1049. },
  1050. changeSupplierModalPage(e) {
  1051. this.modal_supplier_page_index = e;
  1052. this.initSupplierModal(this.modalSupplierData);
  1053. },
  1054. initSupplierModal(searchData) {
  1055. this.axios({
  1056. method: "get",
  1057. url: "/api/supply_list",
  1058. params: {
  1059. page_index: this.modal_supplier_page_index,
  1060. page_size: this.modal_supplier_page_size,
  1061. title: searchData.title,
  1062. code: searchData.code,
  1063. },
  1064. })
  1065. .then((res) => {
  1066. this.modal_supplier_total = res.data.total;
  1067. this.modalSupplierData.tableData = res.data.data;
  1068. })
  1069. .catch((err) => {});
  1070. },
  1071. handleSupplierTreeSlect(arr, row) {
  1072. this.modalSupplierData.code = row.code;
  1073. this.initSupplierModal(this.modalSupplierData);
  1074. },
  1075. },
  1076. // 监听属性 类似于data概念
  1077. computed: {},
  1078. // 监控data中的数据变化
  1079. watch: {},
  1080. beforeCreate() {}, // 生命周期 - 创建之前
  1081. beforeMount() {}, // 生命周期 - 挂载之前
  1082. beforeUpdate() {}, // 生命周期 - 更新之前
  1083. updated() {}, // 生命周期 - 更新之后
  1084. beforeDestroy() {}, // 生命周期 - 销毁之前
  1085. destroyed() {}, // 生命周期 - 销毁完成
  1086. activated() {}, // 如果页面有keep-alive缓存功能,这个函数会触发
  1087. };
  1088. </script>
  1089. <style lang='scss' scoped>
  1090. .content_topform {
  1091. padding-top: 20px;
  1092. /deep/.ivu-form {
  1093. display: flex;
  1094. justify-content: flex-start;
  1095. align-items: flex-start;
  1096. flex-wrap: wrap;
  1097. }
  1098. /deep/.ivu-form-item {
  1099. display: inline-block;
  1100. width: 300px;
  1101. }
  1102. }
  1103. .content_table {
  1104. .content_table_btn {
  1105. display: flex;
  1106. justify-content: space-between;
  1107. align-items: center;
  1108. padding-bottom: 20px;
  1109. }
  1110. .content_table_btn_right {
  1111. display: flex;
  1112. justify-content: flex-start;
  1113. align-items: center;
  1114. }
  1115. }
  1116. .modal_content {
  1117. display: flex;
  1118. justify-content: center;
  1119. overflow: hidden;
  1120. overflow-y: auto;
  1121. .modal_content_left {
  1122. }
  1123. .modal_content_center {
  1124. width: 80%;
  1125. border-left: 1px solid #666;
  1126. border-right: 1px solid #666;
  1127. padding: 0 20px;
  1128. .modal_content_center_top {
  1129. display: flex;
  1130. justify-content: flex-start;
  1131. align-items: center;
  1132. span {
  1133. width: 100px;
  1134. }
  1135. div {
  1136. display: flex;
  1137. justify-content: space-around;
  1138. align-items: center;
  1139. span {
  1140. width: 100px;
  1141. }
  1142. }
  1143. .modal_content_center_body {
  1144. overflow: hidden;
  1145. overflow-y: auto;
  1146. height: 500px;
  1147. }
  1148. }
  1149. .modal_content_center_body {
  1150. padding-top: 20px;
  1151. }
  1152. .modal_content_center_footer {
  1153. display: flex;
  1154. justify-content: center;
  1155. padding-top: 20px;
  1156. }
  1157. }
  1158. .modal_content_right {
  1159. width: 30%;
  1160. padding: 0 20px;
  1161. }
  1162. }
  1163. /deep/ .ivu-table-wrapper {
  1164. overflow: visible;
  1165. } //穿透iview
  1166. </style>