detailsPage.vue 17 KB

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