detailsPage.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. <template>
  2. <div>
  3. <div class="borderless">
  4. <div class="customer-head">
  5. <div class="customer-back">
  6. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left" @click="backToList">
  7. 返回列表
  8. </el-button>
  9. </div>
  10. <div class="add-customer-btn">
  11. <el-button v-if="form.status == 1" size="small" @click="disabled(0)">
  12. 启用
  13. </el-button>
  14. <el-button v-if="form.status == 0" size="small" @click="disabled(1)">
  15. 禁用
  16. </el-button>
  17. <el-button type="primary" size="small" @click="editCustomer">
  18. 保存数据
  19. </el-button>
  20. </div>
  21. </div>
  22. <trade-card title="基础资料" style="margin-top: 60px">
  23. <avue-form ref="form" class="trading-form" v-model="form" :option="option">
  24. <template slot="goodsTypeId">
  25. <div style="display:flex;">
  26. <avue-cascader :emit-path="false" check-strictly :show-all-levels="false" v-model="form.goodsTypeId" placeholder="请选择产品分类" :dic="goodsTypeList" :props="props"></avue-cascader>
  27. <i class="el-icon-circle-plus-outline" style="font-size:18px;line-height: 32px;margin-left:4px" @click="goodsTypeVisible = true"></i>
  28. </div>
  29. </template>
  30. <template slot="unit">
  31. <div style="display:flex;">
  32. <avue-select v-model="form.unit" filterable placeholder="请选择单位" :dic="unitList" :props="props2"></avue-select>
  33. <i class="el-icon-circle-plus-outline" style="font-size:18px;line-height: 32px;margin-left:4px" @click="$refs.dictbiz.open()"></i>
  34. </div>
  35. </template>
  36. <template slot="whether">
  37. <el-switch v-model="form.whether" active-text="是" inactive-text="否" active-value="1" inactive-value="0" @change="whetherChange"/>
  38. </template>
  39. <template slot="whetherIntegral">
  40. <el-switch v-model="form.whetherIntegral" active-text="是" inactive-text="否" active-value="1" inactive-value="0" @change="whetherIntegralChange"/>
  41. </template>
  42. </avue-form>
  43. </trade-card>
  44. <trade-card title="库存管理" v-loading="loadingBtn">
  45. <avue-crud ref="crud" :option="optionList" :data="data" :table-loading="loading" @saveColumn="saveColumn"
  46. @resetColumn="resetColumn" :cell-style="cellStyle" @row-update="rowUpdate" @row-save="rowSave">
  47. <!--<template slot="headerSerial">-->
  48. <!-- <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow"-->
  49. <!-- :disabled="detailData.status == 1" circle></el-button>-->
  50. <!--</template>-->
  51. <template slot="storageIdHeader" slot-scope="{column}">
  52. <span style="color: #409EFF;cursor: pointer" @click.stop="storageVisible = true">仓库</span>
  53. </template>
  54. <template slot="menu" slot-scope="{ row, index }">
  55. <el-button size="small" type="text" @click="rowCell(row, index)">{{ row.$cellEdit ? "保存" : "修改" }}
  56. </el-button>
  57. <!--<el-button size="small" type="text" @click="rowDel(row, index)">删除</el-button>-->
  58. </template>
  59. </avue-crud>
  60. </trade-card>
  61. <containerTitle title="主图附件"></containerTitle>
  62. <c-upload :data="filesList" display deleteUrl="/api/blade-client/goodsfiles/delete" :enumerationValue="160" />
  63. <el-dialog title="设置产品分类" v-dialogDrag :visible.sync="goodsTypeVisible" class="avue-dialog"
  64. width="80%" append-to-body @closed="goodsTypeClosed">
  65. <span>
  66. <!-- <avue-form :key="reload" ref="goodsType" v-model="form2" :option="option2" style="margin-top:20px"></avue-form> -->
  67. <goods-type></goods-type>
  68. </span>
  69. <div class="avue-dialog__footer">
  70. <el-button @click="goodsTypeVisible = false" size="mini">取 消</el-button>
  71. <el-button @click="saveGoodstype" type="primary" size="mini">确 定</el-button>
  72. </div>
  73. </el-dialog>
  74. <el-dialog title="添加仓库" v-dialogDrag :visible.sync="storageVisible" class="avue-dialog avue-dialog--top" width="30%" append-to-body @closed="storageClosed">
  75. <span>
  76. <avue-form :key="reload2" ref="storage" v-model="form3" :option="option3" style="margin-top:20px"></avue-form>
  77. </span>
  78. <div class="avue-dialog__footer">
  79. <el-button @click="storageVisible = false" size="mini">取 消</el-button>
  80. <el-button @click="savestorage" type="primary" size="mini">确 定</el-button>
  81. </div>
  82. </el-dialog>
  83. <dictbiz-dialog ref="dictbiz" title="添加单位" code="unit" parentId="1585962784498225154" @closed="getAllWorkDicts"></dictbiz-dialog>
  84. </div>
  85. </div>
  86. </template>
  87. <script>
  88. import { getGoodstype, getDetails, goodsTypesubmit, getStoragetype, submit, itemRemove, disabled, getStoragelist, storagesubmit } from "@/api/basicData/product";
  89. import { optionList } from "./js/optionList";
  90. import goodsType from '@/components/goodsType/index'
  91. export default {
  92. name: "index",
  93. data() {
  94. return {
  95. loadingBtn: false,
  96. goodsTypeVisible: false,
  97. storageVisible: false,
  98. form: {},
  99. form2: {},
  100. form3: {},
  101. data: [],
  102. option: {
  103. menuBtn: false,
  104. labelWidth: 100,
  105. column: [
  106. {
  107. label: "名称",
  108. prop: "cname",
  109. span: 16,
  110. rules: [{
  111. required: true,
  112. message: "请输入通知标题",
  113. trigger: "blur"
  114. }]
  115. },
  116. {
  117. label: "产品分类",
  118. prop: "goodsTypeId",
  119. type: 'select',
  120. dicData: [],
  121. props: {
  122. label: 'detailedAddress',
  123. value: 'detailedAddress'
  124. },
  125. filterable: true,
  126. span: 8,
  127. rules: [{
  128. required: true,
  129. message: "请输入通知标题",
  130. trigger: "blur"
  131. }]
  132. },
  133. {
  134. label: "单位",
  135. prop: "unit",
  136. type: "select",
  137. props: {
  138. label: "dictValue",
  139. value: "dictValue"
  140. },
  141. dicUrl: "/api/blade-system/dict-biz/dictionary?code=unit",
  142. span: 8,
  143. rules: [{
  144. required: true,
  145. message: "请输入通知标题",
  146. trigger: "blur"
  147. }]
  148. },
  149. {
  150. label: "零售价",
  151. prop: "standardPrice",
  152. type: 'number',
  153. minRows: 0,
  154. controls: false,
  155. span: 8,
  156. rules: [{
  157. required: true,
  158. message: "请输入通知标题",
  159. trigger: "blur"
  160. }]
  161. },
  162. {
  163. label: "售价1",
  164. prop: "wholesalePrice",
  165. type: 'number',
  166. minRows: 0,
  167. controls: false,
  168. span: 8,
  169. rules: [{
  170. required: true,
  171. message: "请输入通知标题",
  172. trigger: "blur"
  173. }]
  174. },
  175. {
  176. label: "售价2",
  177. prop: "repairDepotPrice",
  178. type: 'number',
  179. minRows: 0,
  180. controls: false,
  181. span: 8,
  182. rules: [{
  183. required: true,
  184. message: "请输入通知标题",
  185. trigger: "blur"
  186. }]
  187. },
  188. {
  189. label: "售价3",
  190. prop: "storePrice",
  191. type: 'number',
  192. minRows: 0,
  193. controls: false,
  194. span: 8,
  195. rules: [{
  196. required: true,
  197. message: "请输入通知标题",
  198. trigger: "blur"
  199. }]
  200. },
  201. {
  202. label: "售价4",
  203. prop: "price",
  204. type: 'number',
  205. minRows: 0,
  206. controls: false,
  207. span: 8,
  208. rules: [{
  209. required: true,
  210. message: "请输入通知标题",
  211. trigger: "blur"
  212. }]
  213. },
  214. {
  215. label: "进货价",
  216. prop: "purchasePrice",
  217. type: 'number',
  218. minRows: 0,
  219. controls: false,
  220. span: 8,
  221. rules: [{
  222. required: true,
  223. message: "请输入通知标题",
  224. trigger: "blur"
  225. }]
  226. },
  227. {
  228. label: "特价",
  229. prop: "specialOffer",
  230. type: 'number',
  231. minRows: 0,
  232. controls: false,
  233. span: 8,
  234. rules: [{
  235. required: true,
  236. message: "请输入通知标题",
  237. trigger: "blur"
  238. }]
  239. },
  240. {
  241. label: "销售数量",
  242. prop: "salesVolumes",
  243. type: 'number',
  244. minRows: 0,
  245. controls: false,
  246. span: 8
  247. },
  248. {
  249. label: "标签",
  250. prop: "label",
  251. type: 'checkbox',
  252. dataType: "string",
  253. props: {
  254. label: "dictValue",
  255. value: "dictValue"
  256. },
  257. dicUrl: "/api/blade-system/dict-biz/dictionary?code=label",
  258. span: 8,
  259. },
  260. {
  261. label: "是否管理批次号",
  262. prop: "whether",
  263. labelWidth:120,
  264. span: 8,
  265. rules: [{
  266. required: true,
  267. message: "请输入通知标题",
  268. trigger: "blur"
  269. }]
  270. },
  271. {
  272. label: "是否为积分商品",
  273. prop: "whetherIntegral",
  274. labelWidth:120,
  275. span: 8,
  276. rules: [{
  277. required: true,
  278. message: "请输入通知标题",
  279. trigger: "blur"
  280. }]
  281. },
  282. {
  283. label: "门店积分",
  284. prop: "storeIntegral",
  285. type: 'number',
  286. minRows: 0,
  287. controls: false,
  288. disabled:true,
  289. span: 8,
  290. value:0
  291. },
  292. {
  293. label: "推荐人积分",
  294. prop: "referenceIntegral",
  295. type: 'number',
  296. minRows: 0,
  297. controls: false,
  298. disabled:true,
  299. span: 8,
  300. value:0
  301. },
  302. {
  303. label: "业务员积分",
  304. prop: "salesmanIntegral",
  305. type: 'number',
  306. minRows: 0,
  307. controls: false,
  308. disabled:true,
  309. span: 8,
  310. value:0
  311. },
  312. {
  313. label: "商品积分",
  314. prop: "integral",
  315. type: 'number',
  316. minRows: 0,
  317. controls: false,
  318. disabled:true,
  319. span: 8,
  320. value:0
  321. },
  322. {
  323. label: "备注",
  324. prop: "remarks",
  325. type: "textarea",
  326. minRows: 3,
  327. span: 24,
  328. }
  329. ]
  330. },
  331. option2: {
  332. menuBtn: false,
  333. labelWidth: 80,
  334. column: [
  335. {
  336. label: "分类名称",
  337. prop: "cname",
  338. rules: [
  339. {
  340. required: true,
  341. message: "",
  342. trigger: "blur"
  343. }
  344. ],
  345. span: 24,
  346. },
  347. {
  348. label: "上级类型",
  349. prop: "parentId",
  350. dicData: [],
  351. type: "tree",
  352. props: {
  353. label: "title",
  354. value: "id"
  355. },
  356. span: 24,
  357. }
  358. ]
  359. },
  360. option3: {
  361. menuBtn: false,
  362. labelWidth: 80,
  363. column: [
  364. {
  365. label: "仓库名称",
  366. prop: "cname",
  367. rules: [
  368. {
  369. required: true,
  370. message: "",
  371. trigger: "blur"
  372. }
  373. ],
  374. span: 24,
  375. },
  376. {
  377. label: "仓库编码",
  378. prop: "code",
  379. rules: [
  380. {
  381. required: true,
  382. message: "",
  383. trigger: "blur"
  384. }
  385. ],
  386. span: 24,
  387. },
  388. {
  389. label: "上级类型",
  390. prop: "parentId",
  391. dicData: [],
  392. type: "tree",
  393. props: {
  394. label: 'cname',
  395. value: 'id'
  396. },
  397. span: 24,
  398. }
  399. ]
  400. },
  401. filesList: [],
  402. props: {
  403. label: 'title',
  404. value: 'value'
  405. },
  406. props2: {
  407. label: 'dictValue',
  408. value: 'dictValue'
  409. },
  410. goodsTypeList: [],
  411. unitList: [],
  412. optionList: {}
  413. };
  414. },
  415. components: {
  416. goodsType
  417. },
  418. props: {
  419. detailData: {
  420. type: Object
  421. }
  422. },
  423. async created() {
  424. // 判断是否是admin 权限
  425. let arr = localStorage.getItem('roleName').split(',')
  426. if (arr.indexOf('admin') != -1) {
  427. this.findObject(this.option.column, "storeIntegral").disabled = false
  428. this.findObject(this.option.column, "referenceIntegral").disabled = false
  429. this.findObject(this.option.column, "salesmanIntegral").disabled = false
  430. this.findObject(this.option.column, "integral").disabled = false
  431. }
  432. this.optionList = await this.getColumnData(
  433. this.getColumnName(218),
  434. optionList
  435. );
  436. if (await this.detailData.goodsTypeId){
  437. this.form.goodsTypeId = this.detailData.goodsTypeId;
  438. }
  439. if (this.detailData.id) {
  440. this.getDetail(this.detailData.id);
  441. }
  442. if (this.detailData.status == 1) {
  443. this.option.disabled = true;
  444. }
  445. this.getAllWorkDicts()
  446. },
  447. methods: {
  448. getAllWorkDicts() {
  449. getGoodstype().then(res => {
  450. this.goodsTypeList = res.data.data;
  451. this.findObject(this.option2.column, "parentId").dicData = res.data.data;
  452. });
  453. getStoragelist().then(res => {
  454. this.findObject(this.optionList.column, "storageId").dicData = res.data;
  455. this.findObject(this.option3.column, "parentId").dicData = res.data;
  456. });
  457. this.getWorkDicts("unit").then(res => {
  458. this.unitList = res.data.data;
  459. });
  460. },
  461. cellStyle() {
  462. return "padding:0;height:40px;";
  463. },
  464. addRow() {
  465. this.data.push({$cellEdit: true})
  466. },
  467. rowCell(row, index) {
  468. this.$refs.crud.rowCell(row, index)
  469. },
  470. rowSave(form, done) {
  471. done()
  472. },
  473. rowUpdate(form, index, done) {
  474. done()
  475. },
  476. rowDel(row, index) {
  477. this.$confirm("确定删除数据?", {
  478. confirmButtonText: "确定",
  479. cancelButtonText: "取消",
  480. type: "warning"
  481. }).then(() => {
  482. if (row.id) {
  483. itemRemove({ids: row.id}).then(res => {
  484. this.$message({
  485. type: "success",
  486. message: "删除成功!"
  487. });
  488. this.data.splice(index, 1);
  489. });
  490. } else {
  491. this.$message({
  492. type: "success",
  493. message: "删除成功!"
  494. });
  495. this.data.splice(index, 1);
  496. }
  497. });
  498. },
  499. disabled(val) {
  500. disabled({ id: this.form.id, status: val }).then(res => {
  501. this.getDetail(this.detailData.id);
  502. })
  503. },
  504. saveGoodstype() {
  505. this.$refs["goodsType"].validate((valid, done) => {
  506. done();
  507. if (valid) {
  508. goodsTypesubmit({ ...this.form2, status: 0 }).then(res => {
  509. this.getAllWorkDicts()
  510. })
  511. this.goodsTypeVisible = false
  512. } else {
  513. return false;
  514. }
  515. });
  516. },
  517. savestorage() {
  518. // this.$refs["storage"].validate((valid, done) => {
  519. // done();
  520. // if (valid) {
  521. // storagesubmit({ ...this.form3, status: 0 }).then(res => {
  522. // this.getAllWorkDicts()
  523. // })
  524. // this.storageVisible = false
  525. // } else {
  526. // return false;
  527. // }
  528. // });
  529. this.getAllWorkDicts()
  530. this.goodsTypeVisible = false
  531. },
  532. goodsTypeClosed() {
  533. // this.reload = Math.random();
  534. // this.form2 = this.$options.data().form2
  535. },
  536. storageClosed() {
  537. this.reload2 = Math.random();
  538. this.form3 = this.$options.data().form3
  539. },
  540. getDetail(id) {
  541. this.loadingBtn = true
  542. getDetails({ goodsId: id })
  543. .then(res => {
  544. this.form = res.data.data;
  545. this.data = res.data.data.stockGoodsList;
  546. this.filesList = res.data.data.filesList
  547. this.whetherChange(res.data.data.whether)
  548. })
  549. .finally(() => {
  550. this.loadingBtn = false;
  551. });
  552. },
  553. // 是否为积分商品的change事件
  554. whetherIntegralChange(val){
  555. },
  556. // 是否管理批次号的change事件
  557. whetherChange(val){
  558. console.log(val)
  559. if (val == 0||val==null) {
  560. this.findObject(this.optionList.column, "lotNo").hide = true
  561. this.findObject(this.optionList.column, "lotNo").showColumn = false
  562. } else {
  563. this.findObject(this.optionList.column, "lotNo").hide = false
  564. this.findObject(this.optionList.column, "lotNo").showColumn = true
  565. }
  566. },
  567. //修改提交触发
  568. editCustomer() {
  569. this.$refs["form"].validate((valid, done) => {
  570. done();
  571. if (valid) {
  572. this.loadingBtn = true;
  573. submit({
  574. ...this.form,
  575. code: this.form.cname,
  576. type: 0,
  577. stockGoodsList: this.data,
  578. filesList: this.filesList
  579. }).then(res => {
  580. this.$message.success("保存成功");
  581. this.form = res.data.data;
  582. this.data = res.data.data.stockGoodsList;
  583. this.filesList = res.data.data.filesList;
  584. setTimeout(() => {
  585. this.backToList()
  586. }, 1000);
  587. }).finally(() => {
  588. this.loadingBtn = false;
  589. });
  590. } else {
  591. return false;
  592. }
  593. });
  594. },
  595. async saveColumn() {
  596. const inSave = await this.saveColumnData(
  597. this.getColumnName(218),
  598. this.optionList
  599. );
  600. if (inSave) {
  601. this.$nextTick(() => {
  602. this.$refs.crud.doLayout();
  603. });
  604. this.$message.success("保存成功");
  605. //关闭窗口
  606. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  607. }
  608. },
  609. async resetColumn() {
  610. this.optionList = optionList;
  611. const inSave = await this.delColumnData(
  612. this.getColumnName(218),
  613. optionList
  614. );
  615. if (inSave) {
  616. this.$nextTick(() => {
  617. this.$refs.crud.doLayout();
  618. });
  619. this.getAllWorkDicts()
  620. this.$message.success("重置成功");
  621. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  622. }
  623. },
  624. //返回列表
  625. backToList() {
  626. this.$emit("goBack");
  627. }
  628. },
  629. };
  630. </script>
  631. <style lang="scss" scoped>
  632. .trading-form ::v-deep .el-form-item {
  633. margin-bottom: 8px !important;
  634. }
  635. ::v-deep .el-dialog__body {
  636. padding: 0px 20px 15px 20px;
  637. }
  638. ::v-deep .el-form-item__error {
  639. display: none !important;
  640. }
  641. .img-form ::v-deep .el-form-item {
  642. height: 150px;
  643. line-height: 150px;
  644. margin-bottom: 8px !important;
  645. }
  646. .img-form ::v-deep .avue-upload__icon {
  647. font-size: 20px;
  648. width: 150px;
  649. height: 150px;
  650. line-height: 150px;
  651. }
  652. ::v-deep .el-table .cell {
  653. padding: 0 2px !important;
  654. }
  655. ::v-deep .avue-crud .el-table .el-form-item__label {
  656. left: -1px;
  657. }
  658. .addressTabs {
  659. display: flex;
  660. justify-content: center;
  661. span {
  662. width: 100px;
  663. font-size: 18px;
  664. font-weight: 600;
  665. text-align: center;
  666. }
  667. }
  668. </style>