detailsPage.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. <template>
  2. <div>
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left" @click="goBack()">返回列表 </el-button>
  6. </div>
  7. <div class="add-customer-btn">
  8. <el-button class="el-button--small-yh" style="margin-left: 6px;" type="primary" size="small" v-if="editBtn" @click="inEdit">编 辑 </el-button>
  9. <el-button class="el-button--small-yh" v-else style="margin-left: 6px;" type="primary" size="small" :disabled="editDis" @click="submit"
  10. >保 存
  11. </el-button>
  12. <el-button
  13. v-if="form.id && form.status == 0"
  14. class="el-button--small-yh"
  15. style="margin-left: 6px;"
  16. type="success"
  17. size="small"
  18. :disabled="editDis"
  19. @click="allClick('提交')"
  20. >提交
  21. </el-button>
  22. <el-button
  23. v-if="form.id && form.status == 1"
  24. class="el-button--small-yh"
  25. style="margin-left: 6px;"
  26. type="danger"
  27. size="small"
  28. :disabled="editBtn"
  29. @click="allClick('撤销')"
  30. >撤销
  31. </el-button>
  32. <el-button v-if="form.id" class="el-button--small-yh" style="margin-left: 6px;" size="small" @click="disabledStock"
  33. >{{ Number(form.upAndDownShelves) === 0 ? '启用' : '禁用' }}
  34. </el-button>
  35. </div>
  36. </div>
  37. <div style="margin-top: 50px">
  38. <trade-card title="基础信息">
  39. <avue-form :option="optionForm" v-model="form" ref="form">
  40. <tempalte slot="goodsTypeNameLabel">
  41. <el-tooltip class="item" effect="dark" content="新建分类" placement="top">
  42. <el-button type="text" @click.stop="allClick('新建分类')">分类</el-button>
  43. </el-tooltip>
  44. </tempalte>
  45. <tempalte slot="goodsTypeName">
  46. <dic-select
  47. v-model="form.goodsTypeName"
  48. placeholder="分类"
  49. label="cname"
  50. res="records"
  51. @selectChange="dicChange('goodsTypeName', $event)"
  52. :disabled="optionForm.disabled"
  53. url="/gubersail-admin/goodsType/page?current=1&size=5"
  54. :filterable="true"
  55. :remote="true"
  56. dataName="cname"
  57. ></dic-select>
  58. </tempalte>
  59. <tempalte slot="brandName">
  60. <dic-select
  61. v-model="form.brandName"
  62. placeholder="品牌"
  63. label="cname"
  64. res="records"
  65. @selectChange="dicChange('brandName', $event)"
  66. :disabled="optionForm.disabled"
  67. url="/gubersail-admin/brandDesc/list?current=1&size=5"
  68. :filterable="true"
  69. :remote="true"
  70. dataName="cname"
  71. ></dic-select>
  72. </tempalte>
  73. <tempalte slot="inventoryAmount">
  74. <el-input v-model="inventoryAmountSum" placeholder="库存金额" disabled/>
  75. </tempalte>
  76. <tempalte slot="storageName">
  77. <dic-select
  78. v-model="form.storageName"
  79. placeholder="仓库"
  80. label="cname"
  81. res="records"
  82. @selectChange="dicChange('storageName', $event)"
  83. :disabled="optionForm.disabled"
  84. url="/gubersail-admin/storageDesc/list?current=1&size=5"
  85. :filterable="true"
  86. :remote="true"
  87. dataName="cname"
  88. ></dic-select>
  89. </tempalte>
  90. </avue-form>
  91. </trade-card>
  92. <goods-type ref="goodsType"></goods-type>
  93. <trade-card title="操作记录">
  94. <avue-form :option="optionForm2" v-model="form" ref="form2"> </avue-form>
  95. </trade-card>
  96. </div>
  97. </div>
  98. </template>
  99. <script>
  100. import { submit, detail, submitApprova, revokeApproval, disabledStock } from "@/api/goodsManage/index";
  101. import dicSelect from "@/components/dicSelect/main.vue";
  102. import goodsType from "./components/index.vue";
  103. export default {
  104. name: "detailsPage",
  105. data() {
  106. return {
  107. editBtn: false,
  108. editDis: false,
  109. form: {
  110. claimAttachmentList: [],
  111. bladeClaimAuditList: []
  112. },
  113. optionForm: {
  114. menuBtn: false,
  115. span: 6,
  116. disabled: false,
  117. labelWidth: 100,
  118. column: [
  119. {
  120. label: "商品名称",
  121. prop: "cname",
  122. span: 6,
  123. rules: [
  124. {
  125. required: true,
  126. message: "",
  127. trigger: "blur"
  128. }
  129. ]
  130. },
  131. {
  132. label: "商品编码",
  133. prop: "code",
  134. span: 6,
  135. rules: [
  136. {
  137. required: true,
  138. message: "",
  139. trigger: "blur"
  140. }
  141. ]
  142. },
  143. {
  144. label: "分类",
  145. prop: "goodsTypeName",
  146. span: 6,
  147. rules: [
  148. {
  149. required: true,
  150. message: "",
  151. trigger: "blur"
  152. }
  153. ]
  154. },
  155. {
  156. label: "品牌",
  157. prop: "brandName",
  158. span: 6,
  159. rules: [
  160. {
  161. required: true,
  162. message: "",
  163. trigger: "blur"
  164. }
  165. ]
  166. },
  167. {
  168. label: "批次",
  169. prop: "dot",
  170. span: 6,
  171. rules: [
  172. {
  173. required: true,
  174. message: "",
  175. trigger: "blur"
  176. }
  177. ]
  178. },
  179. {
  180. label: "花纹",
  181. prop: "brandItem",
  182. span: 6,
  183. rules: [
  184. {
  185. required: true,
  186. message: "",
  187. trigger: "blur"
  188. }
  189. ]
  190. },
  191. {
  192. label: "规格型号",
  193. prop: "typeNo",
  194. span: 6,
  195. row: true,
  196. rules: [
  197. {
  198. required: true,
  199. message: "",
  200. trigger: "blur"
  201. }
  202. ]
  203. },
  204. {
  205. label: "售价1",
  206. prop: "priceOne",
  207. span: 6
  208. },
  209. {
  210. label: "售价2",
  211. prop: "priceTwo",
  212. span: 6
  213. },
  214. {
  215. label: "售价3",
  216. prop: "priceThree",
  217. span: 6
  218. },
  219. {
  220. label: "售价4",
  221. prop: "priceFour",
  222. span: 6
  223. },
  224. {
  225. label: "仓库",
  226. prop: "storageName",
  227. span: 6,
  228. rules: [
  229. {
  230. required: true,
  231. message: "",
  232. trigger: "blur"
  233. }
  234. ]
  235. },
  236. {
  237. label: "库存数量",
  238. prop: "balanceQuantity",
  239. span: 6,
  240. type: "number",
  241. min: 1,
  242. max: 99999,
  243. rules: [
  244. {
  245. required: true,
  246. message: "",
  247. trigger: "blur"
  248. }
  249. ]
  250. },
  251. {
  252. label: "库存单价",
  253. prop: "inventoryCostPrice",
  254. type: "number",
  255. min: 0,
  256. max: 99999,
  257. span: 6
  258. },
  259. {
  260. label: "库存金额",
  261. prop: "inventoryAmount",
  262. span: 6,
  263. disabled: true
  264. },
  265. {
  266. label: "商品描述",
  267. prop: "productDescription",
  268. type: "textarea",
  269. span: 12,
  270. minRows: 2
  271. },
  272. {
  273. label: "备注",
  274. prop: "remark",
  275. type: "textarea",
  276. span: 12,
  277. minRows: 2
  278. }
  279. ]
  280. },
  281. optionForm2: {
  282. menuBtn: false,
  283. span: 6,
  284. disabled: false,
  285. labelWidth: 100,
  286. column: [
  287. {
  288. label: "制单人",
  289. prop: "createUserName",
  290. disabled: true
  291. },
  292. {
  293. label: "制单日期",
  294. prop: "createTime",
  295. disabled: true
  296. },
  297. {
  298. label: "修改人",
  299. prop: "updateUserName",
  300. disabled: true
  301. },
  302. {
  303. label: "修改日期",
  304. prop: "updateTime",
  305. disabled: true
  306. }
  307. ]
  308. }
  309. };
  310. },
  311. components: { dicSelect, goodsType },
  312. props: {
  313. detailData: Object
  314. },
  315. computed:{
  316. inventoryAmountSum(){
  317. return Number(this.form.balanceQuantity) * Number(this.form.inventoryCostPrice)
  318. }
  319. },
  320. created() {
  321. if (this.detailData && this.detailData.id) {
  322. this.editBtn = true;
  323. this.editDis = true;
  324. this.optionForm.disabled = true;
  325. this.getDetail(this.detailData.id);
  326. }
  327. },
  328. methods: {
  329. inEdit() {
  330. this.editBtn = false;
  331. if (this.form.status == 0) {
  332. this.editDis = false;
  333. this.optionForm.disabled = false;
  334. }
  335. },
  336. dicChange(name, row) {
  337. if (name == "goodsTypeName") {
  338. if (row) {
  339. this.form.goodsTypeId = row.id;
  340. } else {
  341. this.form.goodsTypeId = null;
  342. this.form.goodsTypeName = null;
  343. }
  344. }
  345. if (name == "brandName") {
  346. if (row) {
  347. this.form.brandId = row.id;
  348. } else {
  349. this.form.brandId = null;
  350. this.form.brandName = null;
  351. }
  352. }
  353. if (name == "storageName") {
  354. if (row) {
  355. this.form.storageId = row.id;
  356. } else {
  357. this.form.storageId = null;
  358. this.form.storageName = null;
  359. }
  360. }
  361. },
  362. allClick(name) {
  363. if (name == "新建分类") {
  364. this.$refs.goodsType.openDialog();
  365. }
  366. if (name == "提交") {
  367. this.$confirm("是否提交?", "提示", {
  368. confirmButtonText: "确定",
  369. cancelButtonText: "取消",
  370. type: "warning"
  371. }).then(() => {
  372. let obj = {
  373. ...this.form
  374. };
  375. submitApprova(obj).then(res => {
  376. this.$message.success("操作成功");
  377. this.getDetail(this.form.id);
  378. });
  379. });
  380. }
  381. if (name == "撤销") {
  382. this.$confirm("是否撤销?", "提示", {
  383. confirmButtonText: "确定",
  384. cancelButtonText: "取消",
  385. type: "warning"
  386. }).then(() => {
  387. revokeApproval({id: this.form.id, version: this.form.version}).then(res => {
  388. this.$message.success("操作成功");
  389. this.getDetail(this.form.id);
  390. });
  391. });
  392. }
  393. },
  394. upDate(data) {
  395. this.form.claimAttachmentList = data;
  396. },
  397. disabledStock() {
  398. let obj = {};
  399. obj = {
  400. id: this.form.id,
  401. version:this.form.version,
  402. upAndDownShelves: this.form.upAndDownShelves == 1 ? 0 : 1
  403. };
  404. // const jsonData = JSON.stringify(obj);
  405. const loading = this.$loading({
  406. lock: true,
  407. text: "加载中",
  408. spinner: "el-icon-loading",
  409. background: "rgba(255,255,255,0.7)"
  410. });
  411. disabledStock(obj)
  412. .then(res => {
  413. this.$message.success("操作成功");
  414. this.getDetail(this.form.id);
  415. })
  416. .finally(() => {
  417. loading.close();
  418. });
  419. },
  420. submit() {
  421. // @ts-ignore
  422. this.$refs.form.validate((valid, done) => {
  423. done();
  424. if (valid) {
  425. const loading = this.$loading({
  426. lock: true,
  427. text: "加载中",
  428. spinner: "el-icon-loading",
  429. background: "rgba(255,255,255,0.7)"
  430. });
  431. submit(this.form)
  432. .then(res => {
  433. this.$message.success("保存成功");
  434. this.getDetail(res.data.data);
  435. })
  436. .finally(() => {
  437. loading.close();
  438. });
  439. } else {
  440. return false;
  441. }
  442. });
  443. },
  444. /**
  445. * @param {any} id
  446. */
  447. getDetail(id) {
  448. const loading = this.$loading({
  449. lock: true,
  450. text: "加载中",
  451. spinner: "el-icon-loading",
  452. background: "rgba(255,255,255,0.7)"
  453. });
  454. detail({ id: id })
  455. .then(res => {
  456. if (res.data.data.status > 0) {
  457. this.editBtn = true;
  458. this.editDis = true;
  459. this.optionForm.disabled = true;
  460. }
  461. if (!this.editBtn && res.data.data.status == 0) {
  462. this.editDis = false;
  463. this.optionForm.disabled = false;
  464. }
  465. this.form = res.data.data;
  466. })
  467. .finally(() => {
  468. loading.close();
  469. });
  470. },
  471. /**
  472. * @param {any} type
  473. */
  474. goBack(type) {
  475. this.$emit("goBack");
  476. }
  477. }
  478. };
  479. </script>
  480. <style lang="scss" scoped>
  481. ::v-deep .el-form-item__error {
  482. display: none !important;
  483. }
  484. ::v-deep .el-form-item {
  485. margin-bottom: 8px !important;
  486. }
  487. ::v-deep .el-table .cell {
  488. padding: 0 2px !important;
  489. .el-form-item {
  490. margin-bottom: 0px !important;
  491. }
  492. }
  493. ::v-deep .el-table--small td,
  494. .el-table--small th {
  495. padding: 2px !important;
  496. }
  497. </style>