edit.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907
  1. <template>
  2. <div>
  3. <Toptitle :title="setTip">
  4. <Button @click="back" type="primary" ghost style="margin-right:10px;"
  5. >返回</Button
  6. >
  7. <Button v-if="type != 3" type="primary" @click="handleSubmit('Info')"
  8. >保存</Button
  9. >
  10. </Toptitle>
  11. <div class="page-edit">
  12. <Form style="display:flex;flex-wrap:wrap" ref="Info" :model="info" :rules="rules" :label-width='120'>
  13. <FormItem label="部件分类名称" prop="p_id" style="width:300px">
  14. <Select v-if="type != 3" filterable clearable v-model="info.p_id">
  15. <Option
  16. v-for="item of partList"
  17. :key="item.id"
  18. :value="item.id"
  19. :label="item.title"
  20. ></Option>
  21. </Select>
  22. <span v-else>{{
  23. partList.length > 0 && info.p_id
  24. ? partList.filter((item) => item.id == info.p_id)[0].title
  25. : ""
  26. }}</span>
  27. </FormItem>
  28. <FormItem label="标签" prop="label" style="width:300px">
  29. <RadioGroup v-model="info.label" style="width:100%;" @on-change='onChange'>
  30. <Radio :disabled="type == 3" :label='1'>是</Radio>
  31. <Radio :disabled="type == 3" :label='0'>否</Radio>
  32. </RadioGroup>
  33. </FormItem>
  34. <FormItem label="打印格式" prop="format" style="width:300px">
  35. <Select v-if="type != 3" filterable clearable v-model="info.format" @on-change='selectOnChange'>
  36. <Option
  37. v-for="item of formatList"
  38. :key="item.id"
  39. :value="item.id"
  40. :label="item.title"
  41. ></Option>
  42. </Select>
  43. <span v-else>{{info.format==0?'不打印':info.format==1?'芯片+标签':info.format==2?'芯片':'标签'}}</span>
  44. </FormItem>
  45. <FormItem label="部件名称" prop="title" style="width:300px">
  46. <Input
  47. v-if="type != 3"
  48. v-model="info.title"
  49. placeholder="请输入部件名称"
  50. />
  51. <span v-else>{{ info.title }}</span>
  52. </FormItem>
  53. <FormItem label="单位" prop="company" style="width:300px">
  54. <Input
  55. v-if="type != 3"
  56. v-model="info.company"
  57. placeholder="请输入单位"
  58. />
  59. <span v-else>{{ info.company }}</span>
  60. </FormItem>
  61. <FormItem label="关联产品分类" prop="p_id">
  62. <div style="display:flex;align-items:center;width:100%;">
  63. <Dropdown v-if="type != 3">
  64. <Button :disabled="type == 3" type="primary" ghost
  65. >选择产品</Button
  66. >
  67. <DropdownMenu slot="list">
  68. <Downtree
  69. @childByValue="handleClick"
  70. :parent="productTypes"
  71. ></Downtree>
  72. </DropdownMenu>
  73. </Dropdown>
  74. <Button style="margin-left:20px;" v-if="nowSelectObj.title">{{
  75. nowSelectObj.title || ""
  76. }}</Button>
  77. </div>
  78. </FormItem>
  79. </Form>
  80. <div class="edit-table-log">
  81. <div>
  82. <span>零部件添加:</span>
  83. <Button
  84. v-if="type != 3"
  85. size="small"
  86. @click="addZeroPart"
  87. type="primary"
  88. ghost
  89. >新增木板</Button
  90. >
  91. </div>
  92. <span class="footer-log"
  93. >备注:适用于 +(加) -(减) ×(乘)
  94. ÷(除)不输入就是不设定公式,支持单项输入)</span
  95. >
  96. </div>
  97. <Table
  98. stripe
  99. border
  100. tooltip
  101. :columns="tableColums"
  102. :data="tableData"
  103. :width="tableWidth"
  104. >
  105. <template slot-scope="{ index }" slot="spare_parts">
  106. <Input
  107. v-if="type != 3"
  108. placeholder="请输入零部件名称"
  109. v-model="tableData[index].spare_parts"
  110. />
  111. <span v-else>{{ tableData[index].spare_parts }}</span>
  112. </template>
  113. <template slot-scope="{ index }" slot="title">
  114. <div>
  115. <Select
  116. filterable
  117. clearable
  118. v-if="type != 3"
  119. label-in-value
  120. @on-change="changeSe($event, index)"
  121. v-model="tableData[index].material_id"
  122. >
  123. <Option
  124. :data-unit="item.unit"
  125. :tag="item.high"
  126. v-for="item of materialWoodList"
  127. :key="item.id"
  128. :value="item.id"
  129. :label="item.title"
  130. ></Option>
  131. </Select>
  132. <span v-else>{{
  133. materialWoodList.length > 0 && tableData[index].material_id
  134. ? materialWoodList.filter(
  135. (item) => item.id == tableData[index].material_id
  136. )[0].title
  137. : ""
  138. }}</span>
  139. </div>
  140. </template>
  141. <template slot-scope="{ index }" slot="number">
  142. <Input
  143. v-if="type != 3"
  144. placeholder="请输入数量"
  145. v-model="tableData[index].number"
  146. />
  147. <span v-else>{{ tableData[index].number }}</span>
  148. </template>
  149. <template slot-scope="{ index }" slot="company">
  150. <!-- <Input
  151. placeholder="请输入单位"
  152. disabled
  153. v-model="tableData[index].company"
  154. /> -->
  155. <span>{{ tableData[index].company }}</span>
  156. </template>
  157. <template slot-scope="{ index }" slot="long">
  158. <Input
  159. v-if="type != 3"
  160. @on-focus="openKey(index, 'long')"
  161. placeholder="请输入高"
  162. v-model="tableData[index].long"
  163. />
  164. <span v-else>{{ tableData[index].long }}</span>
  165. </template>
  166. <template slot-scope="{ index }" slot="wide">
  167. <Input
  168. v-if="type != 3"
  169. @on-focus="openKey(index, 'wide')"
  170. placeholder="请输入宽"
  171. v-model="tableData[index].wide"
  172. />
  173. <span v-else>{{ tableData[index].wide }}</span>
  174. </template>
  175. <template slot-scope="{ index }" slot="thick">
  176. <!-- <Input
  177. disabled
  178. placeholder="自动生成"
  179. v-model="tableData[index].thick"
  180. /> -->
  181. <span>{{ tableData[index].thick }}</span>
  182. </template>
  183. <template slot-scope="{ index }" slot="requirement">
  184. <Select
  185. v-if="type != 3"
  186. placeholder="请选择工艺要求"
  187. v-model="tableData[index].technological_requirement_id"
  188. >
  189. <Option
  190. v-for="item in processRequireList"
  191. :key="item.id"
  192. :value="item.id"
  193. :label="item.title"
  194. ></Option>
  195. </Select>
  196. <span v-else>{{
  197. processRequireList.length > 0 &&
  198. tableData[index].technological_requirement_id
  199. ? processRequireList.filter(
  200. (item) =>
  201. item.id == tableData[index].technological_requirement_id
  202. )[0].title
  203. : ""
  204. }}</span>
  205. </template>
  206. <template slot-scope="{ index }" slot="sub_num">
  207. <Select v-if="type != 3" v-model="tableData[index].sub_num">
  208. <Option :value="0" label="0"></Option>
  209. <Option :value="1" label="1"></Option>
  210. <Option :value="2" label="2"></Option>
  211. </Select>
  212. <span v-else>{{
  213. tableData[index].sub_num == 0
  214. ? 0
  215. : tableData[index].sub_num == 1
  216. ? 1
  217. : 2
  218. }}</span>
  219. </template>
  220. <template slot-scope="{ index }" slot="woodSkinSet">
  221. <Select v-if="type != 3" v-model="tableData[index].veneer_id">
  222. <Option
  223. v-for="item in materialWoodSkinList"
  224. :key="item.id"
  225. :value="item.id"
  226. :label="item.title"
  227. ></Option>
  228. </Select>
  229. <span v-else>{{
  230. materialWoodSkinList.length > 0 && tableData[index].veneer_id
  231. ? materialWoodSkinList.filter(
  232. (item) => item.id == tableData[index].veneer_id
  233. )[0].title
  234. : ""
  235. }}</span>
  236. </template>
  237. <template slot-scope="{ index }" slot="paintSet">
  238. <Select v-if="type != 3" v-model="tableData[index].paint_id">
  239. <Option
  240. v-for="item in materialPaintList"
  241. :key="item.id"
  242. :value="item.id"
  243. :label="item.title"
  244. ></Option>
  245. </Select>
  246. <span v-else>{{
  247. materialPaintList.length > 0 && tableData[index].paint_id
  248. ? materialPaintList.filter(
  249. (item) => item.id == tableData[index].paint_id
  250. )[0].title
  251. : ""
  252. }}</span>
  253. </template>
  254. <template slot-scope="{ row,index }" slot="label">
  255. <Select v-if="type != 3" v-model="tableData[index].label" @on-change='tableLabelchange(row,index)'>
  256. <Option
  257. v-for="item in label"
  258. :key="item.id"
  259. :value="item.id"
  260. :label="item.title"
  261. ></Option>
  262. </Select>
  263. <span v-else>{{row.label==1?'是':'否'}}</span>
  264. </template>
  265. <template slot-scope="{ row,index }" slot="format">
  266. <Select v-if="type != 3" v-model="tableData[index].format" @on-change="tableformatchange($event,index)">
  267. <Option
  268. v-for="item in formatList"
  269. :key="item.id"
  270. :value="item.id"
  271. :label="item.title"
  272. ></Option>
  273. </Select>
  274. <span v-else>{{row.format==0?'否':row.format==1?'芯片+标签':row.format==2?'芯片':'标签'}}</span>
  275. </template>
  276. <template slot="printNum" slot-scope="{ index }">
  277. <Input
  278. placeholder="请输入打印数量"
  279. v-if="type != 3"
  280. v-model="tableData[index].print_num"
  281. />
  282. <span v-else>{{ tableData[index].print_num }}</span>
  283. </template>
  284. <template slot-scope="{ index }" slot="set">
  285. <div style="display:Flex;justify-content:space-around">
  286. <Button
  287. v-if="type != 3"
  288. size="small"
  289. type="primary"
  290. @click="copyParts(tableData, index)"
  291. >复制</Button
  292. >
  293. <Button
  294. v-if="type != 3"
  295. size="small"
  296. type="error"
  297. @click="delItems(tableData, index)"
  298. >删除</Button
  299. >
  300. </div>
  301. </template>
  302. </Table>
  303. <div class="edit-table-log">
  304. <div>
  305. <Button
  306. v-if="type != 3"
  307. size="small"
  308. @click="addMetals"
  309. type="primary"
  310. ghost
  311. >新增五金</Button
  312. >
  313. </div>
  314. </div>
  315. <Table
  316. stripe
  317. border
  318. :columns="metalsTableColums"
  319. :data="metalsTableData"
  320. :width="tableWidth"
  321. >
  322. <template slot-scope="{ index }" slot="slot_metals">
  323. <Select
  324. v-if="type != 3"
  325. @on-change="changeSeMetal($event, index)"
  326. placeholder="请选择"
  327. v-model="metalsTableData[index].material_id"
  328. >
  329. <Option
  330. v-for="item in metalsList"
  331. :data-unit="item.unit"
  332. :key="item.id"
  333. :value="item.id"
  334. :label="item.title"
  335. ></Option>
  336. </Select>
  337. <span v-else>{{
  338. metalsList.length > 0 && metalsTableData[index].material_id
  339. ? metalsList.filter(
  340. (item) => item.id == metalsTableData[index].material_id
  341. )[0].title
  342. : ""
  343. }}</span>
  344. </template>
  345. <template slot-scope="{ index }" slot="slot_metals_number">
  346. <Input
  347. v-if="type != 3"
  348. @on-change="handleTotalPriceCalc(metalsTableData[index])"
  349. placeholder="请输入数量"
  350. v-model="metalsTableData[index].number"
  351. />
  352. <span v-else>{{ metalsTableData[index].number }}</span>
  353. </template>
  354. <template slot-scope="{ index }" slot="slot_metals_unit">
  355. <!-- <Input
  356. placeholder="请输入单位"
  357. disabled
  358. v-model="metalsTableData[index].company"
  359. /> -->
  360. <span>{{ metalsTableData[index].company }}</span>
  361. </template>
  362. <template slot-scope="{ index }" slot="slot_metals_price">
  363. <Input
  364. v-if="type != 3"
  365. placeholder="请输入单价"
  366. @on-change="handleTotalPriceCalc(metalsTableData[index])"
  367. v-model="metalsTableData[index].price"
  368. />
  369. <span v-else>{{ metalsTableData[index].price }}</span>
  370. </template>
  371. <template slot-scope="{ index }" slot="slot_metals_total_price">
  372. <Input
  373. v-if="type != 3"
  374. placeholder="请输入总价"
  375. v-model="metalsTableData[index].total_price"
  376. />
  377. <span v-else>{{ metalsTableData[index].total_price }}</span>
  378. </template>
  379. <template slot-scope="{ index }" slot="slot_metals_set">
  380. <div style="display:Flex;justify-content:space-around">
  381. <Button
  382. v-if="type != 3"
  383. size="small"
  384. type="primary"
  385. @click="copyParts(metalsTableData, index)"
  386. >复制</Button
  387. >
  388. <Button
  389. v-if="type != 3"
  390. size="small"
  391. type="error"
  392. @click="delItems(metalsTableData, index)"
  393. >删除</Button
  394. >
  395. </div>
  396. </template>
  397. </Table>
  398. </div>
  399. <Modal
  400. v-model="showKey"
  401. :width="1250"
  402. :mask-closable="false"
  403. :closable="false"
  404. >
  405. <div>
  406. <KeyBoard
  407. :rightData="measureList"
  408. @cancel="cancelKey"
  409. @success="successKey"
  410. class="key-co"
  411. />
  412. </div>
  413. <div slot="footer"></div>
  414. </Modal>
  415. </div>
  416. </template>
  417. <script>
  418. import KeyBoard from "../../components/keyboard/index";
  419. import Downtree from "../../components/drowDown/index";
  420. export default {
  421. data() {
  422. return {
  423. type: 1,
  424. id: null,
  425. tableWidth: null,
  426. info: {
  427. company: "",
  428. p_id: "",
  429. bp_id: null,
  430. label: 1,
  431. title: "",
  432. format:1
  433. },
  434. partList: [],
  435. partsData: [],
  436. label:[{title:'是',id:1},{title:'否',id:0}],
  437. tableColums: [
  438. {
  439. title: "零部件名称",
  440. align: "center",
  441. key: "spare_parts",
  442. slot: "spare_parts",
  443. resizable: true,
  444. width: 150,
  445. fixed: "left",
  446. },
  447. {
  448. title: "物料名称",
  449. align: "center",
  450. key: "title",
  451. slot: "title",
  452. resizable: true,
  453. width: 150,
  454. },
  455. {
  456. title: "数量",
  457. align: "center",
  458. key: "number",
  459. slot: "number",
  460. resizable: true,
  461. width: 150,
  462. },
  463. {
  464. title: "单位",
  465. align: "center",
  466. key: "company",
  467. slot: "company",
  468. resizable: true,
  469. width: 150,
  470. },
  471. {
  472. title: "高",
  473. align: "center",
  474. key: "long",
  475. slot: "long",
  476. resizable: true,
  477. width: 150,
  478. },
  479. {
  480. title: "宽",
  481. align: "center",
  482. key: "wide",
  483. slot: "wide",
  484. resizable: true,
  485. width: 150,
  486. },
  487. {
  488. title: "厚",
  489. align: "center",
  490. key: "thick",
  491. slot: "thick",
  492. minWidth: 120,
  493. },
  494. {
  495. title: "工艺要求",
  496. align: "center",
  497. key: "requirement",
  498. slot: "requirement",
  499. resizable: true,
  500. width: 150,
  501. },
  502. {
  503. title: "贴木皮名称",
  504. align: "center",
  505. key: "num",
  506. slot: "woodSkinSet",
  507. resizable: true,
  508. width: 150,
  509. },
  510. {
  511. title: "贴面数",
  512. align: "center",
  513. key: "sub_num",
  514. slot: "sub_num",
  515. resizable: true,
  516. width: 150,
  517. },
  518. {
  519. title: "油漆组合",
  520. align: "center",
  521. key: "paint",
  522. slot: "paintSet",
  523. resizable: true,
  524. width: 150,
  525. },
  526. {
  527. title: "是否生成芯片码",
  528. align: "center",
  529. key: "label",
  530. slot: "label",
  531. resizable: true,
  532. width: 150,
  533. },
  534. {
  535. title: "打印格式",
  536. align: "center",
  537. key: "format",
  538. slot: "format",
  539. resizable: true,
  540. width: 150,
  541. },
  542. {
  543. title: "打印数量",
  544. align: "center",
  545. key: "printNum",
  546. slot: "printNum",
  547. resizable: true,
  548. width: 150,
  549. },
  550. {
  551. title: "操作",
  552. align: "center",
  553. slot: "set",
  554. minWidth: 200,
  555. fixed: "right",
  556. },
  557. ],
  558. metalsTableColums: [
  559. {
  560. title: "五金",
  561. align: "center",
  562. key: "spare_parts",
  563. slot: "slot_metals",
  564. resizable: true,
  565. width: 260,
  566. },
  567. {
  568. title: "数量",
  569. align: "center",
  570. key: "number",
  571. slot: "slot_metals_number",
  572. resizable: true,
  573. width: 260,
  574. },
  575. {
  576. title: "单位",
  577. align: "center",
  578. key: "unit",
  579. slot: "slot_metals_unit",
  580. resizable: true,
  581. width: 260,
  582. },
  583. {
  584. title: "单价",
  585. align: "center",
  586. key: "price",
  587. slot: "slot_metals_price",
  588. resizable: true,
  589. width: 260,
  590. },
  591. {
  592. title: "总价",
  593. align: "center",
  594. key: "total_prive",
  595. slot: "slot_metals_total_price",
  596. resizable: true,
  597. width: 260,
  598. },
  599. {
  600. title: "操作",
  601. align: "center",
  602. slot: "slot_metals_set",
  603. minWidth: 200,
  604. }
  605. ],
  606. tableData: [],
  607. metalsTableData: [],
  608. rules: {
  609. p_id: [{ required: true, message: " " }],
  610. label: [{ required: true, message: "请选择标签" }],
  611. title: [{ required: true, message: " ", trigger: "blur" }],
  612. company: [{ required: true, message: " ", trigger: "blur" }],
  613. format: [{ required: true, message: " " }],
  614. },
  615. formatList:[{title:'芯片+标签',id:1},{title:'芯片',id:2},{title:'标签',id:3},{title:'否',id:0}],
  616. addObj: {
  617. title: "",
  618. number: "",
  619. company: "",
  620. spare_parts: "",
  621. long: "",
  622. wide: "",
  623. thick: "",
  624. requirement: "",
  625. label: 1,
  626. format:1,
  627. p_id: null,
  628. },
  629. zeroParts: [],
  630. showKey: false,
  631. attrindex: null,
  632. attrName: "",
  633. measureList: [
  634. { e_title: "H", title: "高", id: 1, sort: 0 },
  635. { e_title: "W", title: "宽", id: 1, sort: 0 },
  636. { e_title: "D", title: "深", id: 1, sort: 0 },
  637. ],
  638. productTypes: [],
  639. nowSelectObj: {},
  640. // 木板列表
  641. materialWoodList: [],
  642. // 木皮列表
  643. materialWoodSkinList: [],
  644. // 油漆列表
  645. materialPaintList: [],
  646. // 工艺要求列表
  647. processRequireList: [],
  648. // 饰面列表
  649. faceList: [],
  650. // 五金列表
  651. metalsList: [],
  652. };
  653. },
  654. mounted() {
  655. this.getProductTypes();
  656. this.getPartsData();
  657. this.type = this.$route.query.type;
  658. this.id = this.$route.query.id;
  659. if (this.id) {
  660. this.getDetails(this.id);
  661. }
  662. this.getParts();
  663. this.tableWidth = window.innerWidth - 350;
  664. window.addEventListener(
  665. "resize",
  666. (e) => (this.tableWidth = e.target.innerWidth - 350)
  667. );
  668. this.axios("/api/material", { params: { sub_type_id: 1 } }).then((res) => {
  669. this.materialWoodList = res.data.data;
  670. });
  671. this.axios("/api/material", { params: { sub_type_id: 2 } }).then((res) => {
  672. this.materialWoodSkinList = res.data.data;
  673. });
  674. this.axios("/api/material_combination").then((res) => {
  675. this.materialPaintList = res.data.data;
  676. });
  677. this.axios("/api/properties_index", { params: { id: 1 } }).then((res) => {
  678. this.faceList = res.data.data;
  679. });
  680. this.axios("/api/material", { params: { sub_type_id: 5 } }).then((res) => {
  681. this.metalsList = res.data.data;
  682. });
  683. this.axios("/api/technological_requirement").then((res) => {
  684. this.processRequireList = res.data.data;
  685. });
  686. },
  687. components: {
  688. KeyBoard,
  689. Downtree,
  690. },
  691. computed: {
  692. setTip() {
  693. const { type } = this.$route.query;
  694. const inner =
  695. type == 1
  696. ? "新增部件"
  697. : type == 2
  698. ? "编辑部件"
  699. : type == 3
  700. ? "查看部件"
  701. : "拷贝部件";
  702. return inner;
  703. },
  704. },
  705. methods: {
  706. tableformatchange(e,index){
  707. if(e==0){
  708. this.tableData[index].label=0
  709. }
  710. },
  711. tableLabelchange(row,index){
  712. if(row.label == 1){
  713. this.tableData[index].format = 0
  714. }
  715. },
  716. selectOnChange(val){
  717. if(val==0){
  718. this.info.label = 0
  719. }
  720. },
  721. onChange(val){
  722. if(val == 0){
  723. this.info.format = 0
  724. }
  725. },
  726. back() {
  727. this.$router.push({ name: "PartsManageHome" });
  728. },
  729. getPartsData() {
  730. this.axios("/api/material").then((res) => {
  731. this.zeroParts = res.data.data;
  732. });
  733. },
  734. getParts() {
  735. this.axios("/api/basics_parts_index").then((res) => {
  736. this.partList = res.data.data;
  737. });
  738. },
  739. postData() {
  740. const { type } = this.$route.query;
  741. if (!this.info.bp_id) {
  742. return this.$Message.warning("请关联产品");
  743. }
  744. let postInfo = JSON.parse(JSON.stringify(this.info)),
  745. sendData = { top: {} };
  746. sendData.op = type == 1 || type == 4 ? "add" : "edit";
  747. type == 4 ? (sendData.id = "") : "";
  748. for (let i in postInfo) {
  749. i == "detail"
  750. ? (sendData.detail = postInfo["detail"])
  751. : (sendData.top[i] = postInfo[i]);
  752. }
  753. sendData.detail = [...this.tableData, ...this.metalsTableData];
  754. this.axios.post("/api/parts_save", sendData).then((res) => {
  755. if (res.code == 200) {
  756. this.$Message.success(res.msg);
  757. this.back();
  758. }
  759. });
  760. },
  761. getDetails(id) {
  762. this.axios("/api/parts_detail", { params: { id: id } }).then((res) => {
  763. this.info = res.data;
  764. this.info.bp_id
  765. ? this.axios("/api/basics_product_list", {
  766. params: { id: this.info.bp_id },
  767. }).then((res) => {
  768. this.measureList = res.data[0].measure;
  769. })
  770. : "";
  771. // this.tableData = res.data.detail;
  772. // 1 木板 2 木皮 3 实木 4 辅料 5 五金 6 油漆
  773. res.data.detail.forEach((element) => {
  774. if (element.type_id == 2 || element.type_id == 1) {
  775. this.tableData.push(element);
  776. } else if (element.type_id == 5) {
  777. element.total_price = element.price * 1 * element.number;
  778. this.metalsTableData.push(element);
  779. }
  780. });
  781. if (this.info.product) {
  782. this.nowSelectObj = this.info.product;
  783. }
  784. this.$route.params.info
  785. ? this.tableData.push(this.$route.params.info)
  786. : "";
  787. });
  788. },
  789. addNewsPart() {
  790. this.$router.push({
  791. name: "PageEdit",
  792. params: {
  793. list: this.list,
  794. title: this.tableData.length >= 1 ? "编辑零部件" : "新增零部件",
  795. type: "零部件",
  796. },
  797. });
  798. },
  799. delItems(row, n) {
  800. row.splice(n, 1);
  801. },
  802. addZeroPart() {
  803. let add = JSON.parse(JSON.stringify(this.addObj));
  804. add.sub_num = 0;
  805. this.tableData.push(add);
  806. },
  807. addMetals() {
  808. let add = JSON.parse(JSON.stringify(this.addObj));
  809. this.metalsTableData.push(add);
  810. },
  811. changeSe(e, n) {
  812. let event = window.event;
  813. let unit = event.target.dataset.unit;
  814. this.tableData[n].company = unit ? unit : "";
  815. this.tableData[n].thick = e.tag;
  816. this.tableData[n].title = e.title;
  817. },
  818. changeSeMetal(e, n) {
  819. let event = window.event;
  820. let unit = event.target.dataset.unit;
  821. this.metalsTableData[n].company = unit ? unit : "";
  822. },
  823. handleSubmit(name) {
  824. this.$refs[name].validate((valid) => {
  825. console.log(valid)
  826. if (valid) {
  827. this.postData();
  828. }
  829. });
  830. },
  831. successKey(str) {
  832. this.tableData[this.attrindex][this.attrName] = str;
  833. this.showKey = false;
  834. },
  835. cancelKey() {
  836. this.showKey = false;
  837. },
  838. openKey(row, attr) {
  839. this.showKey = true;
  840. this.attrindex = row;
  841. this.attrName = attr;
  842. },
  843. getProductTypes(e) {
  844. this.axios("/api/parts_product_list", { params: { id: e } }).then(
  845. (res) => {
  846. if (res.code == 200) {
  847. this.productTypes = res.data;
  848. }
  849. }
  850. );
  851. },
  852. handleClick(e) {
  853. let data = JSON.parse(e);
  854. this.nowSelectObj = data;
  855. this.info.bp_id = this.nowSelectObj.id;
  856. this.axios("/api/basics_product_list", {
  857. params: { id: this.info.bp_id },
  858. }).then((res) => {
  859. this.measureList = res.data[0].measure;
  860. });
  861. },
  862. copyParts(array, n) {
  863. let copy_data = JSON.parse(JSON.stringify(array[n]));
  864. copy_data.id = "";
  865. array.splice(n, 0, copy_data);
  866. },
  867. handleTotalPriceCalc(row) {
  868. row.total_price = row.number * 1 * row.price || 0;
  869. },
  870. },
  871. };
  872. </script>
  873. <style lang="scss" scoped>
  874. .edit-table-log {
  875. display: flex;
  876. justify-content: space-between;
  877. align-items: center;
  878. padding-bottom: 10px;
  879. padding-top: 20px;
  880. .footer-log {
  881. color: #666666;
  882. }
  883. }
  884. .page-edit {
  885. overflow: hidden;
  886. overflow-y: auto;
  887. position: relative;
  888. top: 20px;
  889. height: 80%;
  890. }
  891. /deep/ .ivu-table-wrapper {
  892. overflow: visible;
  893. color: red;
  894. } //穿透iview
  895. /deep/ .ivu-select-dropdown-list {
  896. z-index: 10000;
  897. }
  898. /deep/.ivu-form-item-content {
  899. span {
  900. vertical-align: middle;
  901. }
  902. }
  903. </style>