edit.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964
  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 inline ref="Info" :model="info" :rules="rules" :label-width="120">
  13. <FormItem label="产品分类" prop="bp_id">
  14. <Select
  15. v-if="type != 3"
  16. style="width:300px"
  17. v-model="info.bp_id"
  18. @on-change="changeProduct"
  19. >
  20. <Option
  21. v-for="item of productFiled"
  22. :key="item.id"
  23. :value="item.id"
  24. :label="item.title"
  25. ></Option>
  26. </Select>
  27. <span v-else>{{
  28. productFiled.length > 0 && info.bp_id
  29. ? productFiled.filter((item) => item.id == info.bp_id)[0].title
  30. : ""
  31. }}</span>
  32. </FormItem>
  33. <FormItem label="产品名称" prop="title">
  34. <Input
  35. v-if="type != 3"
  36. v-model="info.title"
  37. style="width:300px"
  38. placeholder="请输入产品名称"
  39. />
  40. <span v-else>{{ info.title }}</span>
  41. </FormItem>
  42. <FormItem label="计量单位" prop="unit">
  43. <Input
  44. v-if="type != 3"
  45. v-model="info.unit"
  46. style="width:300px"
  47. placeholder="请输入计量单位"
  48. />
  49. <span v-else>{{ info.unit }}</span>
  50. </FormItem>
  51. <FormItem label="型号" prop="model">
  52. <Input
  53. v-if="type != 3"
  54. v-model="info.model"
  55. style="width:300px"
  56. placeholder="请输入产品型号"
  57. />
  58. <span v-else>{{ info.model }}</span>
  59. </FormItem>
  60. <FormItem label="图号" prop="title">
  61. <Input
  62. v-if="type != 3"
  63. v-model="info.url_number"
  64. style="width:300px"
  65. placeholder="请输入图号"
  66. />
  67. <span v-else>{{ info.url_number }}</span>
  68. </FormItem>
  69. <!-- <FormItem label="安全预警" prop='title'>
  70. <Input :disabled='type == 3' v-model="info.min_stock" style="width:300px" placeholder="请输入安全预警"></Input>
  71. </FormItem>
  72. <FormItem label="最高预警" prop='title'>
  73. <Input :disabled='type == 3' v-model="info.max_stock" style="width:300px" placeholder="请输入最高预警"></Input>
  74. </FormItem> -->
  75. <!-- <FormItem label="是否加锁">
  76. <div style="display:flex;min-width:300px;">
  77. <RadioGroup v-model="info.lucy_type">
  78. <Radio :disabled='type == 3'
  79. :label="1">是</Radio>
  80. <Radio :disabled='type == 3'
  81. :label="0">否</Radio>
  82. </RadioGroup>
  83. <Select :disabled='type == 3'
  84. v-model="info.luck"
  85. v-if="info.lucy_type == 1"
  86. style="width:150px;">
  87. <Option v-for="item of lucks"
  88. :key="item.id"
  89. :value='item.id'>{{item.title }}</Option>
  90. </Select>
  91. </div>
  92. </FormItem> -->
  93. </Form>
  94. <div class="view-filed">
  95. <span>基础测量字段</span>
  96. <div class="filed-item">
  97. <div v-for="item of measureList" :key="item.id">
  98. {{ item.title }}({{ item.e_title }})
  99. </div>
  100. </div>
  101. </div>
  102. <div class="table-log">
  103. <div>
  104. <span>部件添加:</span>
  105. <Button
  106. :disabled="type == 3"
  107. type="primary"
  108. size="small"
  109. ghost
  110. @click="addPart"
  111. >新增部件</Button
  112. >
  113. </div>
  114. <span>计算公式请使用英文字母参与公式运算,详细请参考例)</span>
  115. </div>
  116. <vxe-table
  117. resizable
  118. border
  119. ref="xTree"
  120. :tree-config="treeConfig"
  121. :data="info.part"
  122. @toggle-tree-expand="toggleExpandChangeEvent"
  123. >
  124. <vxe-table-column field="title" title="部件名称" tree-node>
  125. <template #default="{ row }">
  126. <Select
  127. filterable
  128. v-if="type != 3"
  129. clearable
  130. transfer
  131. v-model="row.part_id"
  132. >
  133. <Option
  134. v-for="(item, key) of parts"
  135. :key="key"
  136. :value="item.id"
  137. :label="item.title"
  138. ></Option>
  139. </Select>
  140. <span v-else>{{
  141. parts.length > 0 && row.part_id
  142. ? parts.filter((item) => item.id == row.part_id)[0].title
  143. : ""
  144. }}</span>
  145. </template>
  146. </vxe-table-column>
  147. <vxe-table-column field="formula_l" title="高(H)">
  148. <template #default="{ row,rowIndex }">
  149. <Input
  150. v-if="type != 3"
  151. @on-focus="openKey(rowIndex, 'formula_l', row)"
  152. clearable
  153. placeholder="请输入公式"
  154. v-model="row.formula_l"
  155. />
  156. <span v-else>{{ row.formula_l }}</span>
  157. </template>
  158. </vxe-table-column>
  159. <vxe-table-column field="formula_w" title="宽(W)">
  160. <template #default="{ row,rowIndex }">
  161. <Input
  162. v-if="type != 3"
  163. @on-focus="openKey(rowIndex, 'formula_w', row)"
  164. clearable
  165. placeholder="请输入公式"
  166. v-model="row.formula_w"
  167. />
  168. <span v-else>{{ row.formula_w }}</span>
  169. </template>
  170. </vxe-table-column>
  171. <vxe-table-column field="formula_h" title="厚(T)">
  172. <template #default="{ row,rowIndex }">
  173. <Input
  174. v-if="type != 3"
  175. @on-focus="openKey(rowIndex, 'formula_h', row)"
  176. clearable
  177. placeholder="请输入公式"
  178. v-model="row.formula_h"
  179. />
  180. <span v-else>{{ row.formula_h }}</span>
  181. </template>
  182. </vxe-table-column>
  183. <vxe-table-column field="ratio" title="产值比例(%)">
  184. <template #default="{ row }">
  185. <Input
  186. v-if="type != 3"
  187. clearable
  188. placeholder="请输入产值比例"
  189. v-model="row.ratio"
  190. />
  191. <span v-else>{{ row.ratio }}</span>
  192. </template>
  193. </vxe-table-column>
  194. <vxe-table-column field="is_null" title="默认为空">
  195. <template #default="{ row }">
  196. <Select
  197. filterable
  198. v-if="type != 3"
  199. clearable
  200. transfer
  201. v-model="row.is_null"
  202. >
  203. <Option :value="1" label="是"></Option>
  204. <Option :value="0" label="否"></Option>
  205. </Select>
  206. <span v-else>{{ row.is_null==1?'是':'否' }}</span>
  207. </template>
  208. </vxe-table-column>
  209. <vxe-table-column field="set" width="180" title="操作">
  210. <template #default="{ row,rowIndex }">
  211. <Button
  212. v-if="type != 3"
  213. size="small"
  214. type="error"
  215. style="margin-right:10px"
  216. @click="delPart(row, rowIndex)"
  217. >删除</Button
  218. >
  219. <Button
  220. size="small"
  221. type="primary"
  222. v-if="row.detail && type != 3"
  223. @click="addReplacePart(info.part, rowIndex)"
  224. >增加替换项</Button
  225. >
  226. </template>
  227. </vxe-table-column>
  228. </vxe-table>
  229. <!-- <Table class="overflow-table"
  230. style="margin-bottom:40px;"
  231. stripe
  232. border
  233. row-key="index"
  234. :columns="tableColums"
  235. :data="info.part">
  236. <template slot='title'
  237. slot-scope='{row,index}'>
  238. <div>
  239. <Select filterable
  240. :disabled='type == 3'
  241. clearable
  242. v-model="row.part_id">
  243. <Option v-for="(item,key) of parts"
  244. :key="key"
  245. :value='item.id'
  246. :label="item.title"></Option>
  247. </Select>
  248. </div>
  249. </template>
  250. <template slot='formula_l'
  251. slot-scope='{row,index}'>
  252. <div>
  253. <Input :disabled='type == 3'
  254. @on-focus="openKey(index,'formula_l',row)"
  255. clearable
  256. placeholder="请输入公式"
  257. v-model="row.formula_l"></Input>
  258. </div>
  259. </template>
  260. <template slot='formula_w'
  261. slot-scope='{row,index}'>
  262. <div>
  263. <Input :disabled='type == 3'
  264. @on-focus="openKey(index,'formula_w',row)"
  265. clearable
  266. placeholder="请输入公式"
  267. v-model="row.formula_w"></Input>
  268. </div>
  269. </template>
  270. <template slot='formula_h'
  271. slot-scope='{row,index}'>
  272. <div>
  273. <Input :disabled='type == 3'
  274. @on-focus="openKey(index,'formula_h',row)"
  275. clearable
  276. placeholder="请输入公式"
  277. v-model="row.formula_h"></Input>
  278. </div>
  279. </template>
  280. <template slot='ratio'
  281. slot-scope='{row,index}'>
  282. <div>
  283. <Input :disabled='type == 3'
  284. clearable
  285. placeholder="请输入产值比例"
  286. v-model="row.ratio"></Input>
  287. </div>
  288. </template>
  289. <template slot='del'
  290. slot-scope='{row,index}'>
  291. <div>
  292. <Button :disabled='type == 3'
  293. size='small'
  294. type="error"
  295. style="margin-right:10px"
  296. @click="delPart(info.part,index)">删除</Button>
  297. <Button :disabled='type == 3'
  298. size='small'
  299. type="primary"
  300. v-show="row.children"
  301. @click="addReplacePart(info.part,index)">增加替换项</Button>
  302. </div>
  303. </template>
  304. </Table> -->
  305. <div class="custom">
  306. <span class="custom-title"
  307. >产品自定义属性
  308. <Button
  309. :disabled="type == 3"
  310. style="margin:10px;margin-left:20px;"
  311. size="small"
  312. type="primary"
  313. @click="addCustom"
  314. ghost
  315. >
  316. 新增自定义属性
  317. </Button>
  318. </span>
  319. <div class="modal-custom">
  320. <div
  321. class="modal-custom-item"
  322. v-for="(item, index) of info.remark"
  323. :key="index"
  324. >
  325. <div class="left">
  326. {{ "自定义属性:" + (index + 1) }}
  327. </div>
  328. <div class="right">
  329. <div class="radio">
  330. <RadioGroup
  331. @on-change="(e) => handleContentTypeChange(e, item)"
  332. v-model="item.type"
  333. >
  334. <Radio :disabled="type == 3" :label="1">输入框</Radio>
  335. <Radio :disabled="type == 3" :label="2">单选框</Radio>
  336. </RadioGroup>
  337. </div>
  338. <div
  339. class="attr"
  340. style="display:flex;flex-wrap:wrap;justify-content: flex-start;"
  341. >
  342. <Input
  343. :disabled="type == 3"
  344. v-model="item.title"
  345. style="width:180px;margin-right: 30px;"
  346. placeholder="请输入属性名称"
  347. ></Input>
  348. <Input
  349. :disabled="type == 3"
  350. v-if="item.type == 1"
  351. v-model="item.content"
  352. style="width:360px;"
  353. placeholder="请输入属性内容"
  354. ></Input>
  355. <div v-else>
  356. <div
  357. v-for="(_item, _index) in item.content"
  358. style="width:300px;display:flex;align-content: flex-end;align-items: center;flex-wrap:wrap;padding-bottom:10px"
  359. :key="_item + '' + _index"
  360. >
  361. <Input
  362. :disabled="type == 3"
  363. v-model="_item.value"
  364. style="width:240px;"
  365. placeholder="请输入属性内容"
  366. ></Input>
  367. <Icon
  368. type="ios-add"
  369. @click="handleContentAdd(item.content)"
  370. size="24"
  371. />
  372. <Icon
  373. type="ios-remove"
  374. v-show="item.content.length != 1"
  375. @click="handleContentRemove(item.content, _index)"
  376. size="24"
  377. />
  378. </div>
  379. </div>
  380. </div>
  381. </div>
  382. <Icon
  383. v-if="type != 3"
  384. @click="delItems(index, info.remark)"
  385. size="20"
  386. class="delete-img"
  387. type="ios-close-circle"
  388. />
  389. </div>
  390. </div>
  391. </div>
  392. <div class="product-img">
  393. <span>产品图片</span>
  394. <div class="product-add">
  395. <div class="items" v-for="(item, index) of info.img" :key="index">
  396. <img @click="looks(item)" :src="$store.state.ip + item" alt="" />
  397. <Icon
  398. v-if="type != 3"
  399. size="20"
  400. @click="delItems(index, info.img)"
  401. class="delete-img"
  402. type="ios-close-circle"
  403. />
  404. </div>
  405. <div class="add-items" v-if="type != 3">
  406. <div class="item">
  407. <Icon size="50" type="ios-add" />
  408. </div>
  409. <span>支持jpg/png格式</span>
  410. <input
  411. @change="changeIpt($event, info.img)"
  412. type="file"
  413. class="ipt"
  414. />
  415. </div>
  416. </div>
  417. </div>
  418. <div class="product-img">
  419. <span>图纸</span>
  420. <div class="product-add">
  421. <div class="items" v-for="(item, index) of info.url" :key="index">
  422. <img @click="looks(item)" :src="$store.state.ip + item" alt="" />
  423. <Icon
  424. v-if="type != 3"
  425. size="20"
  426. @click="delItems(index, info.url)"
  427. class="delete-img"
  428. type="ios-close-circle"
  429. />
  430. </div>
  431. <div class="add-items" v-if="type != 3">
  432. <div class="item">
  433. <Icon size="50" type="ios-add" />
  434. </div>
  435. <span>支持jpg/png格式</span>
  436. <input
  437. @change="changeIpt($event, info.url)"
  438. type="file"
  439. class="ipt"
  440. />
  441. </div>
  442. </div>
  443. </div>
  444. <Modal
  445. v-model="showKey"
  446. :width="1250"
  447. :mask-closable="false"
  448. :closable="false"
  449. >
  450. <div>
  451. <KeyBoard
  452. :rightData="measureList"
  453. @cancel="cancelKey"
  454. @success="successKey"
  455. class="key-co"
  456. />
  457. </div>
  458. <div slot="footer"></div>
  459. </Modal>
  460. </div>
  461. </div>
  462. </template>
  463. <script>
  464. import KeyBoard from "../../components/keyboard/index";
  465. import XEUtils from "xe-utils";
  466. export default {
  467. data() {
  468. return {
  469. type: 1,
  470. id: null,
  471. addImgList: [], //上传图片列表
  472. customList: [], //自定义属性列表
  473. customInfo: {}, //自定义属性对象
  474. productFiled: [],
  475. measureList: [], //基础测量展示字段(仅展示)
  476. lucks: [],
  477. tableColums: [
  478. {
  479. title: "部件名称",
  480. align: "center",
  481. key: "title",
  482. slot: "title",
  483. tree: true,
  484. },
  485. {
  486. title: "高(H)",
  487. align: "center",
  488. key: "formula_l",
  489. slot: "formula_l",
  490. },
  491. {
  492. title: "宽(W)",
  493. align: "center",
  494. key: "formula_w",
  495. slot: "formula_w",
  496. },
  497. {
  498. title: "厚(T)",
  499. align: "center",
  500. key: "formula_h",
  501. slot: "formula_h",
  502. },
  503. { title: "产值比例(%)", align: "center", key: "ratio", slot: "ratio" },
  504. { title: "操作", align: "center", slot: "del", minWidth: 100 },
  505. ],
  506. showCustom: false, //
  507. info: {
  508. model: "", //类型
  509. bp_id: "", //产品类型
  510. title: "", //名称
  511. unit: "", //单位
  512. img: [], //图片列表
  513. part: [], //部件,
  514. remark: [], //自定义属性列表
  515. lock: 0,
  516. lucy_type: 0,
  517. id: "",
  518. url: [],
  519. url_number: "",
  520. },
  521. rules: {
  522. bp_id: [{ required: true, message: " " }],
  523. model: [{ required: true, message: " ", trigger: "blur" }],
  524. title: [{ required: true, message: " ", trigger: "blur" }],
  525. unit: [{ required: true, message: " ", trigger: "blur" }],
  526. },
  527. addObj: {
  528. title: "",
  529. formula_l: "",
  530. formula_w: "",
  531. formula_h: "",
  532. ratio: "",
  533. url: "",
  534. url_number: "",
  535. },
  536. parts: [],
  537. showKey: false,
  538. attrindex: null,
  539. attrName: "",
  540. headers: { Authorization: localStorage.getItem("token") },
  541. currencyChoose: {},
  542. treeConfig: { children: "detail" },
  543. };
  544. },
  545. created() {
  546. this.changeProduct(this.$route.query.back_id);
  547. },
  548. mounted() {
  549. this.getPartsData(this.$route.query.back_id);
  550. this.type = this.$route.query.type || 1;
  551. this.id = this.$route.query.id || null;
  552. this.info.bp_id =
  553. this.type == 1 ? this.$route.query.back_id * 1 : this.info.bp_id;
  554. if (this.id) {
  555. this.getData(this.id);
  556. }
  557. this.getLocks();
  558. },
  559. components: {
  560. KeyBoard,
  561. },
  562. computed: {
  563. setTip() {
  564. const { type } = this.$route.query;
  565. const inner =
  566. type == 1
  567. ? "新增产品"
  568. : type == 2
  569. ? "编辑产品"
  570. : type == 3
  571. ? "查看产品"
  572. : "拷贝产品";
  573. return inner;
  574. },
  575. },
  576. methods: {
  577. postData() {
  578. if (this.info.part.length < 1) {
  579. return this.$Message.warning("请新增部件");
  580. }
  581. const val = this.info.part.reduce(
  582. (pre, cur) => (pre += cur.ratio * 1),
  583. 0
  584. );
  585. console.log(val);
  586. if (val != 100) {
  587. return this.$Message.error("产值比列不匹配");
  588. }
  589. const { type } = this.$route.query;
  590. if (type == 1 || type == 4) {
  591. if (type == 4) {
  592. this.info.id = "";
  593. }
  594. this.info.op = "add";
  595. } else {
  596. this.info.op = "edit";
  597. }
  598. let data = JSON.parse(JSON.stringify(this.info));
  599. data.img = JSON.stringify(data.img);
  600. data.url = JSON.stringify(data.url);
  601. data.part = JSON.stringify(data.part);
  602. data.remark = JSON.stringify(data.remark);
  603. this.axios.post("/api/product_edit", data).then((res) => {
  604. if (res.code == 200) {
  605. this.$Message.success(res.msg);
  606. setTimeout(() => {
  607. this.$router.push({
  608. path: "/cms/product/index",
  609. query: {
  610. title: this.$route.query.title || this.$route.params.title,
  611. id: this.$route.query.back_id || this.$route.params.back_id,
  612. },
  613. });
  614. }, 500);
  615. }
  616. });
  617. },
  618. back() {
  619. this.$router.push({
  620. path: "/cms/product/index",
  621. query: {
  622. id: this.$route.query.back_id ? this.$route.query.back_id : "",
  623. title: this.$route.query.title || this.$route.query.title || "",
  624. },
  625. });
  626. },
  627. goPage(n, row) {
  628. this.$router.push({
  629. name: "PageEdit",
  630. params: {
  631. title: this.info.part.length >= 1 ? "编辑部件" : "新增部件",
  632. list: this.list,
  633. type: "部件",
  634. },
  635. });
  636. },
  637. handleContentTypeChange(val, item) {
  638. val == 1 ? (item.content = "") : (item.content = [{ value: "" }]);
  639. this.$forceUpdate();
  640. },
  641. openCustom() {
  642. this.showCustom = true;
  643. },
  644. delItems(n, arr) {
  645. arr.splice(n, 1);
  646. },
  647. addCustom() {
  648. //添加自定义属性
  649. if (this.info.remark.length == 0) {
  650. this.info.remark = [{title:'',content:'',type:1}];
  651. }else{
  652. this.info.remark.push({ title: "", content: "", type: 1 });
  653. }
  654. },
  655. postImg(file, row) {
  656. let formData = new FormData();
  657. formData.append("file", file);
  658. this.axios.post("/api/upload_pic", formData).then((res) => {
  659. row.push(res.data.url);
  660. });
  661. },
  662. changeIpt(e, row) {
  663. if (this.info.img.length >= 3) {
  664. return this.$Message.warning("图片最多上传3张");
  665. }
  666. let file = e.target.files[0];
  667. this.postImg(file, row);
  668. e.target.value = null;
  669. },
  670. getProductFiledData(id) {
  671. this.axios("/api/basics_product_index").then((res) => {
  672. this.productFiled = res.data.data;
  673. });
  674. },
  675. getData(row) {
  676. this.axios("/api/product", { params: { id: row } }).then((res) => {
  677. this.info = res.data;
  678. if (!this.info.url) {
  679. this.info.url = [];
  680. }
  681. this.info.part.forEach((element, index) => {
  682. element.detail.forEach((elem, idx) => {
  683. elem.index = index + "," + idx;
  684. });
  685. });
  686. });
  687. },
  688. getPartsData(id) {
  689. this.axios("/api/parts_index").then((res) => {
  690. this.parts = res.data.data;
  691. });
  692. },
  693. addPart() {
  694. let add = JSON.parse(JSON.stringify(this.addObj));
  695. add.index = this.info.part.length;
  696. add.detail = [];
  697. this.info.part.push(add);
  698. },
  699. addReplacePart(row, n) {
  700. let add = JSON.parse(JSON.stringify(this.addObj));
  701. add.index = n + "," + row[n].detail.length;
  702. add.formula_h = row[n].formula_h;
  703. add.formula_l = row[n].formula_l;
  704. add.formula_w = row[n].formula_w;
  705. row[n].detail.push(add);
  706. },
  707. toggleExpandChangeEvent() {},
  708. delPart(row, n) {
  709. // row.splice(n, 1)
  710. if (row.detail) {
  711. this.info.part.splice(n, 1);
  712. } else {
  713. console.log("row :>> ", row);
  714. // let idx = row.index.split(",");
  715. // this.info.part[idx[0]].detail.splice(idx[1], 1);
  716. console.log("this.treeConfig :>> ", this.treeConfig);
  717. const matchObj = XEUtils.findTree(
  718. this.info.part,
  719. (item) => item === row,
  720. this.treeConfig
  721. );
  722. if (matchObj) {
  723. // 从树节点中移除
  724. matchObj.items.splice(matchObj.index, 1);
  725. }
  726. }
  727. },
  728. openKey(row, attr, cur) {
  729. this.showKey = true;
  730. this.attrindex = row;
  731. this.attrName = attr;
  732. this.currencyChoose = cur;
  733. },
  734. successKey(str) {
  735. // this.info.part[this.attrindex][this.attrName] = str;
  736. this.currencyChoose[this.attrName] = str;
  737. this.showKey = false;
  738. },
  739. cancelKey() {
  740. this.showKey = false;
  741. },
  742. handleSubmit(name) {
  743. this.$refs[name].validate((valid) => {
  744. if (valid) {
  745. this.postData();
  746. }
  747. });
  748. },
  749. changeProduct(e) {
  750. this.axios("/api/basics_product_list", { params: { id: e } }).then(
  751. (res) => {
  752. if (res.code == 200) {
  753. const { data } = res;
  754. const result = data.filter((rows) => rows.id == e);
  755. this.productFiled = data;
  756. this.measureList = result[0].measure;
  757. }
  758. }
  759. );
  760. this.getPartsData(e);
  761. },
  762. uploadSuccess(e) {
  763. this.info.url = e.data.url;
  764. },
  765. getLocks() {
  766. this.axios("/api/lock_list").then((res) => {
  767. if (res.code == 200) {
  768. this.lucks = res.data;
  769. }
  770. });
  771. },
  772. looks(img) {
  773. const array = [{ img_url: img }];
  774. this.$previewImg({
  775. list: array,
  776. baseUrl: this.$store.state.ip,
  777. baseImgField: "img_url",
  778. baseTitleField: "",
  779. });
  780. },
  781. handleContentAdd(list) {
  782. list.push({});
  783. },
  784. handleContentRemove(list, index) {
  785. list.splice(index, 1);
  786. },
  787. },
  788. };
  789. </script>
  790. <style lang="scss" scoped>
  791. /deep/.ivu-table-cell {
  792. display: flex;
  793. align-items: center;
  794. }
  795. .page-edit {
  796. overflow: hidden;
  797. overflow-y: auto;
  798. position: relative;
  799. top: 20px;
  800. height: 85%;
  801. }
  802. .product-img {
  803. padding-top: 10px;
  804. }
  805. .product-add {
  806. padding: 10px 0;
  807. display: flex;
  808. flex-wrap: wrap;
  809. .ipt {
  810. position: absolute;
  811. width: 100%;
  812. height: 100%;
  813. opacity: 0;
  814. cursor: pointer;
  815. outline: none;
  816. top: 0;
  817. left: 0;
  818. }
  819. .add-items {
  820. width: 120px;
  821. height: 120px;
  822. border: 1px dotted #e7e7e7;
  823. border-radius: 5px;
  824. display: flex;
  825. justify-content: center;
  826. align-items: center;
  827. overflow: hidden;
  828. position: relative;
  829. flex-direction: column;
  830. background: #f4f5f7;
  831. .item {
  832. width: 46px;
  833. height: 46px;
  834. background: #3764ff;
  835. opacity: 0.6;
  836. display: flex;
  837. justify-content: center;
  838. align-items: center;
  839. border-radius: 50%;
  840. color: #fff;
  841. }
  842. }
  843. .items {
  844. width: 120px;
  845. height: 120px;
  846. margin-bottom: 10px;
  847. display: flex;
  848. justify-content: center;
  849. align-items: center;
  850. background: #e7e7e7;
  851. margin-right: 10px;
  852. border-radius: 5px;
  853. position: relative;
  854. img {
  855. max-width: 108px;
  856. max-height: 108px;
  857. }
  858. }
  859. }
  860. .delete-img {
  861. position: absolute;
  862. right: 10px;
  863. top: 10px;
  864. color: red;
  865. }
  866. .custom {
  867. display: flex;
  868. flex-direction: column;
  869. .custom-item {
  870. display: flex;
  871. align-items: center;
  872. padding: 10px 0;
  873. }
  874. }
  875. .table-log {
  876. display: flex;
  877. justify-content: space-between;
  878. align-items: center;
  879. padding: 10px 0;
  880. }
  881. .modal-custom {
  882. width: 100%;
  883. padding: 10px 0;
  884. display: flex;
  885. flex-wrap: wrap;
  886. .modal-custom-item {
  887. width: 600px;
  888. align-items: center;
  889. position: relative;
  890. border-radius: 5px;
  891. margin-right: 20px;
  892. margin-bottom: 20px;
  893. box-shadow: 0 2px 7px rgba(0, 0, 0, 0.15);
  894. border-color: transparent;
  895. position: relative;
  896. .left {
  897. width: 100%;
  898. padding: 10px;
  899. background: #f4f8ff;
  900. }
  901. .right {
  902. width: 100%;
  903. border-radius: 5px;
  904. padding: 10px;
  905. .attr {
  906. display: flex;
  907. justify-content: space-between;
  908. margin: 5px;
  909. }
  910. }
  911. }
  912. .modal-custom-add {
  913. display: flex;
  914. justify-content: center;
  915. align-items: center;
  916. flex-direction: column;
  917. height: 109px;
  918. border: 1px dotted #e7e7e7;
  919. margin-top: 10px;
  920. }
  921. }
  922. .view-filed {
  923. padding: 10px 0;
  924. .filed-item {
  925. padding: 10px 0;
  926. display: flex;
  927. div {
  928. padding: 10px 10px;
  929. &:after {
  930. content: "|";
  931. margin-left: 20px;
  932. color: #dedede;
  933. }
  934. &:last-child {
  935. &:after {
  936. content: "";
  937. }
  938. }
  939. }
  940. }
  941. }
  942. /deep/ .ivu-table-wrapper {
  943. overflow: visible;
  944. color: red;
  945. } //穿透iview
  946. // .key-co{transform: scale(.9);}
  947. /deep/.ivu-form-item-content {
  948. span {
  949. vertical-align: middle;
  950. }
  951. }
  952. </style>