index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  1. <template>
  2. <div>
  3. <FullPage
  4. :title="$route.query.title"
  5. :list="list"
  6. @init="init"
  7. :loading="loading"
  8. @searchData="init"
  9. @changePage="changePage"
  10. @changeSize="changeSize"
  11. :tableColums="tableColums"
  12. :tableData="tableData"
  13. :pageIndex="pageIndex"
  14. :total="total"
  15. >
  16. <div slot="titleButton" style="display:flex;">
  17. <Upload
  18. v-if="persimissionData['批量导入'] || persimissionData.all"
  19. name="your_file"
  20. :show-upload-list="false"
  21. :headers="headers"
  22. :on-error="uploadError"
  23. :on-success="uploadSuccess"
  24. :action="$store.state.ip + '/api/product_import'"
  25. >
  26. <Button type="success" ghost icon="md-exit" style="margin-right:10px;"
  27. >批量导入</Button
  28. >
  29. </Upload>
  30. <Button
  31. v-if="persimissionData['批量导出'] || persimissionData.all"
  32. @click="exportData"
  33. type="warning"
  34. ghost
  35. icon="md-return-left"
  36. style="margin-right:10px;"
  37. >批量导出</Button
  38. >
  39. <!-- v-if="persimissionData['批改替换项'] || persimissionData.all" -->
  40. <Button
  41. type="primary"
  42. ghost
  43. @click="replaceItem"
  44. style="margin-right:10px;"
  45. >批改替换项</Button
  46. >
  47. <Button
  48. v-if="persimissionData['新增产品'] || persimissionData.all"
  49. type="primary"
  50. ghost
  51. icon="md-add"
  52. @click="goPage(1)"
  53. >新增产品</Button
  54. >
  55. </div>
  56. <div slot="navButton"></div>
  57. <template slot="set" slot-scope="{ row }">
  58. <div class="table-set">
  59. <svg
  60. style="font-size:20px"
  61. color="#3764FF"
  62. @click="goPage(4, row)"
  63. class="icon icon-nav"
  64. aria-hidden="true"
  65. >
  66. <use xlink:href="#iconcopy-01"></use>
  67. </svg>
  68. <svg
  69. v-if="persimissionData['编辑'] || persimissionData.all"
  70. style="font-size:20px"
  71. color="#3764FF"
  72. @click="goPage(2, row)"
  73. class="icon icon-nav"
  74. aria-hidden="true"
  75. >
  76. <use xlink:href="#iconbianji"></use>
  77. </svg>
  78. <svg
  79. style="font-size:20px"
  80. color="green"
  81. @click="goPage(3, row)"
  82. class="icon icon-nav"
  83. aria-hidden="true"
  84. >
  85. <use xlink:href="#iconxiangqing"></use>
  86. </svg>
  87. <svg
  88. v-if="persimissionData['删除'] || persimissionData.all"
  89. @click="delItems(row)"
  90. class="icon icon-nav"
  91. style="font-size:20px"
  92. color="red"
  93. aria-hidden="true"
  94. >
  95. <use xlink:href="#iconshanchu"></use>
  96. </svg>
  97. </div>
  98. </template>
  99. </FullPage>
  100. <Modal
  101. v-model="showModal"
  102. :title="'批改替换项:' + $route.query.title"
  103. width="1300"
  104. >
  105. <div class="show_modal_content">
  106. <div class="show_modal_content_left">
  107. <div class="show_modal_content_left_item">
  108. <div class="show_modal_content_left_item_title">
  109. <Button
  110. type="primary"
  111. style="cursor:default;border-radius:0"
  112. :ghost="!isSelectAll"
  113. @click="handleProductAllClick(tableData)"
  114. >产品名称</Button
  115. >
  116. </div>
  117. <div class="show_modal_content_left_item_detail_warp">
  118. <div
  119. class="show_modal_content_left_item_detail"
  120. v-for="product in tableData"
  121. :key="product.id"
  122. >
  123. <Button
  124. type="primary"
  125. :ghost="!product.isSelect"
  126. style="border-radius:10px"
  127. @click="handleProductClick(product, 2)"
  128. >{{ product.title }}</Button
  129. >
  130. </div>
  131. </div>
  132. </div>
  133. <div class="show_modal_content_left_item">
  134. <div class="show_modal_content_left_item_title">
  135. <Button
  136. type="primary"
  137. style="cursor:default;border-radius:0"
  138. ghost
  139. >部件名称</Button
  140. >
  141. </div>
  142. <div v-if="productPartList.length < 1">
  143. <Button type="primary" ghost style="border-radius:10px"
  144. >无</Button
  145. >
  146. <Button type="primary" ghost style="border-radius:10px;margin-left:20px" @click="add"
  147. ><Icon type="md-add" :size='20'/></Button
  148. >
  149. </div>
  150. <div v-else class="show_modal_content_left_item_detail_warp" >
  151. <div
  152. class="show_modal_content_left_item_detail"
  153. v-for="part in productPartList"
  154. :key="part.id"
  155. id="content_left_item"
  156. >
  157. <svg t="1638267575516" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3395" width="200" height="200" style="position: relative;left: 6px;top: -10px;" @click="edit(part)"><path d="M1005.037624 158.992107 899.701554 264.044722 759.214916 123.967406 864.587825 18.915815c19.389606-19.335371 50.835805-19.335371 70.225411 0l70.224388 70.047356C1024.42723 108.297518 1024.42723 139.656737 1005.037624 158.992107zM267.31879 614.19145l140.484591 140.091642-187.231265 46.62183L267.31879 614.19145zM864.587825 299.04998l-421.387259 420.210457L302.75179 579.203588l421.352467-420.211481L864.587825 299.04998zM113.70518 181.723831l0 728.575594 728.57764 0L842.28282 363.868241l109.289102-72.858378 0 692.146916c0 27.535123-8.895601 36.429701-36.432771 36.429701L54.296115 1019.58648c-27.535123 0-49.875944-22.305005-49.875944-49.841152L4.420171 108.866477c0-27.535123 8.858762-36.429701 36.428677-36.429701l692.14794 0L623.709733 181.723831 113.70518 181.723831z" p-id="3396" fill="#707070"></path></svg>
  158. <!-- <Icon type="md-create" style="position: relative;left: 10px;top: -8px;" color='black' :size='10'/> -->
  159. <Button
  160. type="primary"
  161. :ghost="!part.isSelect"
  162. style="border-radius:10px"
  163. @click="handlePartClick(part, 3)"
  164. >{{ part.title }}</Button
  165. >
  166. <svg t="1638267935515" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5634" width="200" height="200" style="position: relative;left: -8px;top: -10px;" @click="del"><path d="M585.412525 512.594747L973.601616 124.418586c19.600808-19.600808 19.600808-51.898182 0-71.49899l-2.120404-2.120404c-19.600808-19.600808-51.898182-19.600808-71.49899 0L511.793131 439.518384 123.61697 50.799192c-19.600808-19.600808-51.898182-19.600808-71.49899 0l-2.120404 2.120404c-20.11798 19.600808-20.11798 51.898182 0 71.49899l388.189091 388.189091L49.997576 900.783838c-19.587879 19.600808-19.587879 51.898182 0 71.49899l2.120404 2.120404c19.600808 19.600808 51.898182 19.600808 71.49899 0L511.793131 586.214141l388.189091 388.176162c19.600808 19.600808 51.898182 19.600808 71.49899 0l2.120404-2.120404c19.600808-19.600808 19.600808-51.898182 0-71.49899L585.412525 512.594747z m0 0" p-id="5635" fill="#707070"></path></svg>
  167. <!-- <Icon type="md-close" style="position: relative;left: -10px;top: -8px;" color='black' :size='20'/> -->
  168. </div>
  169. <Button type="primary" ghost style="border-radius:10px;margin-left:10px" @click="add"
  170. ><Icon type="md-add" :size='20'/></Button
  171. >
  172. </div>
  173. </div>
  174. </div>
  175. <div class="show_modal_content_right">
  176. <div style="margin-top:20px">
  177. <span style="padding-right:10px"
  178. >默认部件:{{ defaultPart.title }}</span
  179. >
  180. <span
  181. >高:<Input v-model="defaultPart.formula_l" style="width:50px"
  182. /></span>
  183. <span
  184. >宽:<Input v-model="defaultPart.formula_w" style="width:50px"
  185. /></span>
  186. <span
  187. >厚:<Input v-model="defaultPart.formula_h" style="width:50px"
  188. /></span>
  189. <span>是否为空: <vxe-switch v-model="defaultPart.is_null"></vxe-switch> </span>
  190. </div>
  191. <div class="show_modal_content_right_top">
  192. <Button type="primary" @click="handleAddChangeable"
  193. >新增替换部件</Button
  194. >
  195. </div>
  196. <div class="show_modal_content_right_body">
  197. <Table
  198. border
  199. max-height="500"
  200. :columns="changeableColumns"
  201. :data="changeableTableData"
  202. ></Table>
  203. </div>
  204. </div>
  205. </div>
  206. <div slot="footer">
  207. <Button
  208. type="primary"
  209. style="margin-right:10px;"
  210. @click="showModal = false"
  211. >取消</Button
  212. >
  213. <Button
  214. type="primary"
  215. style="margin-right:10px;"
  216. @click="handleChangeableConfirm"
  217. >确定</Button
  218. >
  219. </div>
  220. </Modal>
  221. <Modal
  222. v-model="showKey"
  223. :width="1250"
  224. :mask-closable="false"
  225. :closable="false"
  226. >
  227. <div>
  228. <KeyBoard
  229. :rightData="measureList"
  230. @cancel="cancelKey"
  231. @success="successKey"
  232. class="key-co"
  233. />
  234. </div>
  235. <div slot="footer"></div>
  236. </Modal>
  237. <Modal
  238. v-model="edit_showModel"
  239. title="批量修改部件"
  240. width="400"
  241. :draggable='true'
  242. >
  243. <Form :model='formData' >
  244. <FormItem >
  245. <span>默认部件:</span>
  246. <Select v-model="formData.edit_part" style="width:140px">
  247. <Option v-for="item in productPartList" :key="item.id" :value="item.id">
  248. {{item.title}}
  249. </Option>
  250. </Select>
  251. </FormItem>
  252. <FormItem >
  253. <span>高:</span><Input type="number" style='width:60px;margin-right:20px' v-model="defaultPart.formula_l"/>
  254. <span>宽:</span><Input type="number" style='width:60px;margin-right:20px' v-model="defaultPart.formula_w"/>
  255. <span>厚:</span><Input type="number" style='width:60px' v-model="defaultPart.formula_h"/>
  256. </FormItem>
  257. <FormItem>
  258. <span>是否为空: <vxe-switch v-model="defaultPart.is_null"></vxe-switch> </span>
  259. </FormItem>
  260. </Form>
  261. </Modal>
  262. <Modal title="批量修改部件"
  263. width="400"
  264. v-model="del_showModel"
  265. >
  266. <div style="text-align:center">是否确定删除该部件?</div>
  267. </Modal>
  268. <Modal
  269. v-model="add_showModel"
  270. title="批量增加部件"
  271. width="400"
  272. :draggable='true'
  273. >
  274. <Form :model='formData' >
  275. <FormItem >
  276. <span>默认部件:</span>
  277. <Select v-model="formData.edit_part" style="width:140px">
  278. <Option v-for="item in productPartList" :key="item.id" :value="item.id">
  279. {{item.title}}
  280. </Option>
  281. </Select>
  282. </FormItem>
  283. <FormItem >
  284. <span>高:</span><Input type="number" style='width:60px;margin-right:20px' v-model="defaultPart.formula_l"/>
  285. <span>宽:</span><Input type="number" style='width:60px;margin-right:20px' v-model="defaultPart.formula_w"/>
  286. <span>厚:</span><Input type="number" style='width:60px' v-model="defaultPart.formula_h"/>
  287. </FormItem>
  288. <FormItem>
  289. <span>是否为空: <vxe-switch v-model="defaultPart.is_null"></vxe-switch> </span>
  290. </FormItem>
  291. </Form>
  292. </Modal>
  293. </div>
  294. </template>
  295. <script>
  296. import { mapState } from "vuex";
  297. import KeyBoard from "../../components/keyboard/index";
  298. export default {
  299. components: { KeyBoard },
  300. data() {
  301. return {
  302. add_showModel:false,
  303. edit_showModel:false,
  304. del_showModel:false,
  305. formData:{
  306. edit_part:null,
  307. },
  308. list: [
  309. {
  310. title: "产品名称",
  311. name: "Input",
  312. value: "",
  313. serverName: "title",
  314. placeholder: "请输入产品名称",
  315. },
  316. {
  317. title: "产品型号",
  318. name: "Input",
  319. value: "",
  320. serverName: "model",
  321. placeholder: "请输入产品型号",
  322. },
  323. {
  324. title: "图号",
  325. name: "Input",
  326. value: "",
  327. serverName: "url_number",
  328. placeholder: "请输入图号",
  329. },
  330. ],
  331. tableColums: [
  332. {
  333. title: "序号",
  334. type: "index",
  335. align: "center",
  336. key: "",
  337. resizable: true,
  338. width: 70,
  339. },
  340. { title: "分类名称", align: "center", key: "type_name", resizable: true,width:190 },
  341. { title: "产品名称", align: "center", key: "title" , resizable: true,width:190},
  342. { title: "计量单位", align: "center", key: "unit" , resizable: true,width:190},
  343. { title: "型号", align: "center", key: "model", resizable: true,width:190 },
  344. { title: "图号", align: "center", key: "url_number", resizable: true,width:190 },
  345. {
  346. title: "产品图片",
  347. align: "center",
  348. key: "company",
  349. resizable: true,width:190,
  350. render: (h, params) => {
  351. const { row } = params;
  352. return h("img", {
  353. attrs: {
  354. src: params.row.img_url?this.$store.state.ip + params.row.img_url:'',
  355. style:
  356. "max-width:50px;max-height:50px;position:relative;top:3px;",
  357. },
  358. on: {
  359. click: (e) => {
  360. this.axios("/api/orders_img", {
  361. params: { id: row.id, type: 0 },
  362. }).then((res) => {
  363. console.log(
  364. "this.$store.state.ip :>> ",
  365. this.$store.state.ip
  366. );
  367. if (res.code == 200) {
  368. row.imgs = res.data;
  369. this.$previewImg({
  370. list: res.data,
  371. baseUrl: this.$store.state.ip,
  372. baseImgField: "img_url",
  373. baseTitleField: "",
  374. });
  375. }
  376. });
  377. // if(row.imgs&&row.imgs.length>0){//优化处理考虑到图纸我就暂时不处理了
  378. // this.$previewImg({
  379. // list:row.imgs,
  380. // baseUrl:this.$store.state.ip,
  381. // baseImgField:'img_url',
  382. // baseTitleField:''
  383. // })
  384. // }else{
  385. // this.axios('/api/orders_img',{params:{id:row.id,type:0}}).then(res=>{
  386. // if(res.code == 200){
  387. // row.imgs = res.data
  388. // this.$previewImg({
  389. // list:row.imgs,
  390. // baseUrl:this.$store.state.ip,
  391. // baseImgField:'img_url',
  392. // baseTitleField:''
  393. // })
  394. // }
  395. // })
  396. // }
  397. },
  398. },
  399. });
  400. },
  401. },
  402. {
  403. title: "图纸",
  404. align: "center",
  405. key: "url",
  406. resizable: true,width:190,
  407. render: (h, params) => {
  408. const { row } = params;
  409. return h("img", {
  410. attrs: {
  411. src: params.row.url?this.$store.state.ip + params.row.url:'',
  412. style:
  413. "max-width:50px;max-height:50px;position:relative;top:3px;",
  414. },
  415. on: {
  416. click: (e) => {
  417. this.axios("/api/orders_img", {
  418. params: { id: row.id, type: 1 },
  419. }).then((res) => {
  420. if (res.code == 200) {
  421. row.imgs = res.data;
  422. this.$previewImg({
  423. list: row.imgs,
  424. baseUrl: this.$store.state.ip,
  425. baseImgField: "img_url",
  426. baseTitleField: "",
  427. });
  428. }
  429. });
  430. },
  431. },
  432. });
  433. },
  434. },
  435. { title: "操作", align: "center", slot: "set", minWidth: 150 },
  436. ],
  437. tableData: [],
  438. pageIndex: 1,
  439. total: 0,
  440. pageSize: 10,
  441. proxyObj: {
  442. page_index: 1,
  443. page_size: 10,
  444. },
  445. loading: false,
  446. headers: { Authorization: localStorage.getItem("token") },
  447. showModal: false,
  448. productPartList: [],
  449. currentProductList: [],
  450. changeableColumns: [
  451. {
  452. title: "替换部件",
  453. align: "center",
  454. key: "part_id",
  455. render: (h, params) => {
  456. const { index } = params;
  457. const currencyRow = this.changeableTableData[index];
  458. return h(
  459. "Select",
  460. {
  461. props: {
  462. value: currencyRow.part_id,
  463. size: "small",
  464. transfer: true,
  465. clearable: true,
  466. filterable: true,
  467. },
  468. on: {
  469. "on-change": (e) => {
  470. currencyRow.part_id = e;
  471. },
  472. },
  473. },
  474. [
  475. this.partsList.map((item) => {
  476. return h("Option", {
  477. props: { label: item.title, value: item.id },
  478. });
  479. }),
  480. ]
  481. );
  482. },
  483. },
  484. {
  485. title: "高",
  486. align: "center",
  487. key: "formula_l",
  488. width: "100px",
  489. render: (h, params) => {
  490. const { index } = params;
  491. const currencyRow = this.changeableTableData[index];
  492. return h("Input", {
  493. props: {
  494. placeholder: "请输入高",
  495. value: currencyRow.formula_l,
  496. disabled: this.isChecked,
  497. },
  498. on: {
  499. "on-focus": () => {
  500. this.openKey(index, "formula_l", currencyRow);
  501. },
  502. },
  503. });
  504. },
  505. },
  506. {
  507. title: "宽",
  508. align: "center",
  509. key: "formula_w",
  510. width: "100px",
  511. render: (h, params) => {
  512. const { index } = params;
  513. const currencyRow = this.changeableTableData[index];
  514. return h("Input", {
  515. props: {
  516. placeholder: "请输入宽",
  517. value: currencyRow.formula_w,
  518. },
  519. on: {
  520. "on-focus": () => {
  521. this.openKey(index, "formula_w", currencyRow);
  522. },
  523. },
  524. });
  525. },
  526. },
  527. {
  528. title: "厚",
  529. align: "center",
  530. key: "formula_h",
  531. width: "100px",
  532. render: (h, params) => {
  533. const { index } = params;
  534. const currencyRow = this.changeableTableData[index];
  535. return h("Input", {
  536. props: {
  537. placeholder: "请输入厚",
  538. value: currencyRow.formula_h,
  539. },
  540. on: {
  541. "on-focus": () => {
  542. this.openKey(index, "formula_h", currencyRow);
  543. },
  544. },
  545. });
  546. },
  547. },
  548. {
  549. title: "操作",
  550. align: "center",
  551. key: "set",
  552. width: "100px",
  553. render: (h, params) => {
  554. const { index } = params;
  555. // const currencyRow = this.changeableTableData[index];
  556. return h(
  557. "a",
  558. {
  559. on: {
  560. click: () => {
  561. this.changeableTableData.splice(index, 1);
  562. },
  563. },
  564. },
  565. "删除"
  566. );
  567. },
  568. },
  569. ],
  570. changeableTableData: [],
  571. partsList: [],
  572. showKey: false,
  573. measureList: [],
  574. currencyChoose: {},
  575. attrindex: null,
  576. attrName: "",
  577. isSelectAll: false,
  578. defaultPart: {
  579. title: "",
  580. formula_l: "",
  581. formula_w: "",
  582. formula_h: "",
  583. is_null: "",
  584. },
  585. };
  586. },
  587. beforeRouteLeave(to, from, next) {
  588. if (to.path == "/cms/product/edit") {
  589. this.$route.meta.keepAlive = true;
  590. } else {
  591. this.$route.meta.keepAlive = false;
  592. }
  593. next();
  594. },
  595. beforeRouteEnter(to, from, next) {
  596. next((vm) => {
  597. vm.getData(vm.proxyObj);
  598. });
  599. },
  600. created() {
  601. // 获取部件列表
  602. this.axios("/api/parts_index").then((res) => {
  603. this.partsList = res.data.data;
  604. });
  605. // 获取产品分类测量字段
  606. this.axios("/api/basics_product_list", {
  607. params: { id: this.$route.query.id },
  608. }).then((res) => {
  609. if (res.code == 200) {
  610. const { data } = res;
  611. const result = data.filter((rows) => rows.id == this.$route.query.id);
  612. this.measureList = result[0].measure;
  613. }
  614. });
  615. },
  616. mounted() {
  617. this.proxyObj.type_id = this.$route.query.id;
  618. this.getData(this.proxyObj);
  619. },
  620. computed: {
  621. ...mapState(["persimissionData"]),
  622. },
  623. watch: {
  624. "$route.query.title": {
  625. handler() {
  626. this.proxyObj.type_id = this.$route.query.id;
  627. this.list.forEach((element) => {
  628. element.value = "";
  629. });
  630. this.proxyObj.model = "";
  631. this.proxyObj.title = "";
  632. this.getData(this.proxyObj);
  633. },
  634. },
  635. },
  636. methods: {
  637. replaceItem(){
  638. this.showModal = true;
  639. },
  640. add(){
  641. this.add_showModel = true;
  642. },
  643. del(){
  644. this.del_showModel = true;
  645. },
  646. init(row) {
  647. this.pageIndex = 1;
  648. row.page_index = this.pageIndex;
  649. row.page_size = this.pageSize;
  650. row.type_id = this.$route.query.id; //产品管理因为无法使用id 所以用type_id替代
  651. this.proxyObj = row;
  652. this.getData(row);
  653. },
  654. getData(row) {
  655. this.loading = true;
  656. this.axios("/api/product", { params: row }).then((res) => {
  657. this.loading = false;
  658. this.tableData = res.data.data;
  659. this.total = res.data.total;
  660. this.tableData.map((item) => (item.isSelect = false));
  661. });
  662. },
  663. delItems(row) {
  664. this.confirmDelete({
  665. content: "确认删除么?",
  666. then: () => {
  667. this.axios
  668. .post("/api/product", { id: row.id, state: 0 })
  669. .then((res) => {
  670. if (res.code == 200) {
  671. this.$Message.success(res.msg);
  672. this.getData(this.proxyObj);
  673. }
  674. });
  675. },
  676. });
  677. },
  678. handleProductAllClick(product) {
  679. this.isSelectAll = !this.isSelectAll;
  680. // let flag
  681. product.map((item) => {
  682. item.isSelect = this.isSelectAll;
  683. });
  684. let ids = product.map((item) => item.id);
  685. this.isSelectAll &&
  686. this.axios
  687. .post("/api/support_product_get_part", {
  688. type: 2,
  689. basic_product_id: [this.$route.query.id],
  690. product_id: ids,
  691. part_id: [],
  692. })
  693. .then((res) => {
  694. console.log(res);
  695. this.productPartList = res.data;
  696. this.productPartList.map((item) => (item.isSelect = false));
  697. });
  698. },
  699. handleProductClick(product, type) {
  700. product.isSelect = !product.isSelect;
  701. this.currentProductList = product;
  702. const temp_product = this.tableData.filter((item) => item.isSelect);
  703. const product_id = temp_product.map((item) => item.id);
  704. // 判断是否全选,全选标题选中
  705. let flag = true;
  706. this.tableData.map((item) => {
  707. if (!item.isSelect) {
  708. flag = false;
  709. }
  710. });
  711. this.isSelectAll = flag;
  712. this.axios
  713. .post("/api/support_product_get_part", {
  714. type,
  715. basic_product_id: [this.$route.query.id],
  716. product_id,
  717. part_id: [],
  718. })
  719. .then((res) => {
  720. console.log(res);
  721. this.productPartList = res.data;
  722. this.productPartList.map((item) => (item.isSelect = false));
  723. });
  724. this.$forceUpdate();
  725. },
  726. handlePartClick(part, type) {
  727. // 部件单选
  728. this.productPartList.map((item) => (item.isSelect = false));
  729. part.isSelect = !part.isSelect;
  730. const temp_product = this.tableData.filter((item) => item.isSelect);
  731. const product_id = temp_product.map((item) => item.id);
  732. const temp_part = this.productPartList.filter((item) => item.isSelect);
  733. const part_id = temp_part.map((item) => item.id);
  734. this.axios
  735. .post("/api/support_product_get_part", {
  736. type,
  737. basic_product_id: [this.$route.query.id],
  738. product_id,
  739. part_id,
  740. })
  741. .then((res) => {
  742. console.log(res);
  743. this.changeableTableData = res.data.list;
  744. this.defaultPart = res.data.head;
  745. this.defaultPart.title = part.title;
  746. });
  747. this.$forceUpdate();
  748. },
  749. handleAddChangeable() {
  750. const temp = this.productPartList.filter((item) => item.isSelect);
  751. if (temp.length > 0) {
  752. this.changeableTableData.push({
  753. id: "",
  754. formula_h: "",
  755. formula_l: "",
  756. formula_w: "",
  757. });
  758. } else {
  759. this.$Message.warning("请选择部件名称");
  760. }
  761. },
  762. handleChangeableConfirm() {
  763. const temp_product = this.tableData.filter((item) => item.isSelect);
  764. const product_id = temp_product.map((item) => item.id);
  765. const temp_part = this.productPartList.filter((item) => item.isSelect);
  766. const part_id = temp_part.map((item) => item.id);
  767. this.axios
  768. .post("/api/support_product_batch", {
  769. type: 3,
  770. basic_product_id: [this.$route.query.id],
  771. product_id,
  772. part_id,
  773. change: this.changeableTableData,
  774. head: this.defaultPart,
  775. })
  776. .then((res) => {
  777. if (res.code == 200) {
  778. this.$Message.success(res.msg);
  779. this.tableData.map((item) => (item.isSelect = false));
  780. this.productPartList = [];
  781. this.changeableTableData = [];
  782. this.showModal = false;
  783. }
  784. });
  785. },
  786. openKey(row, attr, cur) {
  787. this.showKey = true;
  788. this.attrindex = row;
  789. this.attrName = attr;
  790. this.currencyChoose = cur;
  791. },
  792. successKey(str) {
  793. // this.info.part[this.attrindex][this.attrName] = str;
  794. this.currencyChoose[this.attrName] = str;
  795. this.showKey = false;
  796. },
  797. cancelKey() {
  798. this.showKey = false;
  799. },
  800. changePage(e) {
  801. this.pageIndex = e;
  802. this.proxyObj.page_index = this.pageIndex;
  803. // const sortList = this.sortList.filter((item) => item.sort);
  804. // this.proxyObj.sortList = sortList;
  805. this.getData(this.proxyObj);
  806. },
  807. changeSize(e) {
  808. this.pageSize = e;
  809. this.proxyObj.page_size = this.pageSize;
  810. // const sortList = this.sortList.filter((item) => item.sort);
  811. // this.proxyObj.sortList = sortList;
  812. this.getData(this.proxyObj);
  813. },
  814. edit(val){
  815. this.productPartList.forEach(v=>{
  816. v.isSelect = false;
  817. })
  818. val.isSelect = !val.isSelect
  819. this.edit_showModel = true;
  820. },
  821. goPage(n, row) {
  822. //n = 1 新增 2 编辑 3 查看
  823. let id = row ? row.id : "";
  824. this.$router.push({
  825. path: "/cms/product/edit",
  826. query: {
  827. type: n,
  828. id: id,
  829. back_id: this.$route.query.id,
  830. title: this.$route.query.title,
  831. },
  832. });
  833. },
  834. async exportData() {
  835. const res = await this.axios("/api/product_export", {
  836. params: { ...this.proxyObj },
  837. });
  838. if (res.code == 200) {
  839. let url = `${this.$store.state.ip}/api/storage/${res.data.file}`;
  840. location.href = url;
  841. }
  842. },
  843. uploadSuccess(res) {
  844. if (res.code == 200) {
  845. this.$Message.success(res.msg || "上传成功");
  846. } else {
  847. this.$Message.warning(res.msg || "上传失败");
  848. }
  849. this.getData(this.proxyObj);
  850. },
  851. uploadError(err) {
  852. this.$Message.error(err.msg || "上传失败");
  853. },
  854. },
  855. };
  856. </script>
  857. <style lang="scss" scoped>
  858. .show_modal_content {
  859. display: flex;
  860. .show_modal_content_left {
  861. width: 50%;
  862. min-height: 500px;
  863. overflow: hidden;
  864. overflow-y: auto;
  865. border-right: 1px solid #e8eaec;
  866. padding-top: 20px;
  867. .show_modal_content_left_item {
  868. width: 100%;
  869. display: flex;
  870. .show_modal_content_left_item_title,
  871. .show_modal_content_left_item_detail {
  872. margin-bottom: 10px;
  873. margin-right: 20px;
  874. }
  875. .show_modal_content_left_item_detail_warp {
  876. display: flex;
  877. justify-content: flex-start;
  878. align-items: flex-start;
  879. flex-wrap: wrap;
  880. }
  881. }
  882. }
  883. .show_modal_content_right {
  884. width: 50%;
  885. padding-left: 20px;
  886. .show_modal_content_right_top {
  887. display: flex;
  888. justify-content: flex-end;
  889. margin-top: 30px;
  890. margin-bottom: 10px;
  891. }
  892. }
  893. }
  894. </style>