detailsPage.vue 17 KB

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