shopOperation.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <el-page-header
  5. @back="onCancel"
  6. :content="pageTitle[pageType] + '商品'"
  7. ></el-page-header>
  8. </h2>
  9. <div class="m-core">
  10. <el-form
  11. :model="form"
  12. :rules="rules"
  13. ref="form"
  14. label-width="160px"
  15. :inline="true"
  16. >
  17. <el-alert
  18. title="基础信息"
  19. :closable="false"
  20. class="alert"
  21. type="info"
  22. />
  23. <el-form-item label="货号" prop="sn">
  24. <el-input
  25. v-model.trim="form.sn"
  26. :disabled="pageDisabled"
  27. placeholder="请输入货号"
  28. style="width: 220px !important"
  29. ></el-input>
  30. </el-form-item>
  31. <el-form-item label="品牌" prop="brand">
  32. <el-input
  33. v-model.trim="form.brand"
  34. :disabled="pageDisabled"
  35. placeholder="请输入品牌"
  36. style="width: 220px !important"
  37. ></el-input>
  38. </el-form-item>
  39. <!-- <el-form-item label="备查货号" prop="supplyChannel" v-if="pageType == 'create'">
  40. <el-input v-model.trim="form.supplyChannel" placeholder="请输入备查货号" style="width: 400px"></el-input>
  41. </el-form-item> -->
  42. <el-form-item label="商品名称" prop="name">
  43. <el-input
  44. v-model.trim="form.name"
  45. placeholder="请输入商品名称"
  46. :disabled="pageDisabled"
  47. style="width: 220px !important"
  48. ></el-input>
  49. </el-form-item>
  50. <el-form-item label="商品类型" prop="type">
  51. <el-select
  52. v-model.trim="form.type"
  53. placeholder="请选择商品类型"
  54. :disabled="pageDisabled"
  55. style="width: 220px !important"
  56. >
  57. <el-option
  58. v-for="(item, index) in goodsType"
  59. :key="index"
  60. :label="item.label"
  61. :value="item.value"
  62. ></el-option>
  63. </el-select>
  64. </el-form-item>
  65. <el-form-item label="商品分类" prop="goodsCategoryId">
  66. <el-select
  67. v-model.trim="form.goodsCategoryId"
  68. placeholder="请选择商品分类"
  69. :disabled="pageDisabled"
  70. style="width: 220px !important"
  71. filterable
  72. >
  73. <el-option
  74. v-for="item in categoryList"
  75. :key="item.value"
  76. :label="item.label"
  77. :value="item.value"
  78. >
  79. </el-option>
  80. </el-select>
  81. </el-form-item>
  82. <!-- <el-form-item label="所属分部" prop="organIdList">
  83. <select-all
  84. v-model.trim="form.organIdList"
  85. filterable
  86. placeholder="请选择所属分部"
  87. style="width: 400px !important"
  88. multiple
  89. :disabled="pageDisabled || pageType == 'update'"
  90. clearable
  91. >
  92. <el-option
  93. v-for="item in selects.branchs"
  94. :key="item.id"
  95. :label="item.name"
  96. :value="item.id.toString()"
  97. ></el-option>
  98. </select-all>
  99. </el-form-item> -->
  100. <el-form-item label="商品型号" prop="specification">
  101. <el-input
  102. v-model.trim="form.specification"
  103. placeholder="请输入商品型号"
  104. :disabled="pageDisabled"
  105. style="width: 220px"
  106. ></el-input>
  107. </el-form-item>
  108. <el-form-item label="库存类型" prop="stockType">
  109. <el-select
  110. v-model="form.stockType"
  111. placeholder="请选择库存类型"
  112. :disabled="pageDisabled"
  113. style="width: 220px !important"
  114. >
  115. <el-option
  116. v-for="(item, index) in stockType"
  117. :key="index"
  118. :label="item.label"
  119. :value="item.value"
  120. ></el-option>
  121. </el-select>
  122. </el-form-item>
  123. <el-form-item label="是否库存预警" prop="stockWarning">
  124. <el-select
  125. v-model="form.stockWarning"
  126. placeholder="请选择库存预警"
  127. :disabled="pageDisabled"
  128. style="width: 220px !important"
  129. >
  130. <el-option label="是" :value="1"></el-option>
  131. <el-option label="否" :value="0"></el-option>
  132. </el-select>
  133. </el-form-item>
  134. <el-alert
  135. title="价格信息"
  136. :closable="false"
  137. class="alert"
  138. type="info"
  139. />
  140. <el-form-item label="市场价" prop="marketPrice">
  141. <el-input
  142. type="number"
  143. placeholder="请输入市场价"
  144. :disabled="pageDisabled"
  145. @mousewheel.native.prevent
  146. v-model.trim="form.marketPrice"
  147. style="width: 220px"
  148. ></el-input>
  149. </el-form-item>
  150. <el-form-item label="零售价" prop="discountPrice">
  151. <el-input
  152. type="number"
  153. placeholder="请输入零售价"
  154. @mousewheel.native.prevent
  155. :disabled="pageDisabled"
  156. v-model.trim="form.discountPrice"
  157. style="width: 220px"
  158. ></el-input>
  159. </el-form-item>
  160. <el-form-item label="商品团购价" prop="groupPurchasePrice">
  161. <el-input
  162. type="number"
  163. placeholder="请输入商品团购价"
  164. @mousewheel.native.prevent
  165. :disabled="pageDisabled"
  166. v-model.trim="form.groupPurchasePrice"
  167. style="width: 220px"
  168. ></el-input>
  169. </el-form-item>
  170. <el-alert
  171. title="销售渠道"
  172. :closable="false"
  173. class="alert"
  174. type="info"
  175. />
  176. <el-form-item label="学员可见分部" prop="studentShowOrganId">
  177. <select-all
  178. v-model.trim="form.studentShowOrganId"
  179. filterable
  180. placeholder="请选择所属分部"
  181. style="width: 400px !important"
  182. multiple
  183. :disabled="pageDisabled"
  184. clearable
  185. >
  186. <el-option
  187. v-for="item in selects.branchs"
  188. :key="item.id"
  189. :label="item.name"
  190. :value="item.id.toString()"
  191. ></el-option>
  192. </select-all>
  193. </el-form-item>
  194. <el-form-item label="管理端可见分部" prop="educationShowOrganId">
  195. <select-all
  196. v-model.trim="form.educationShowOrganId"
  197. filterable
  198. placeholder="请选择所属分部"
  199. style="width: 400px !important"
  200. multiple
  201. :disabled="pageDisabled "
  202. clearable
  203. >
  204. <el-option
  205. v-for="item in selects.branchs"
  206. :key="item.id"
  207. :label="item.name"
  208. :value="item.id.toString()"
  209. ></el-option>
  210. </select-all>
  211. </el-form-item>
  212. <el-form-item label="课程&AMR可见分部" prop="courseFeeShowOrganId">
  213. <select-all
  214. v-model.trim="form.courseFeeShowOrganId"
  215. filterable
  216. placeholder="请选择课程&AMR可见分部"
  217. style="width: 400px !important"
  218. multiple
  219. :disabled="pageDisabled"
  220. clearable
  221. >
  222. <el-option
  223. v-for="item in selects.branchs"
  224. :key="item.id"
  225. :label="item.name"
  226. :value="item.id.toString()"
  227. ></el-option>
  228. </select-all>
  229. </el-form-item>
  230. <el-form-item label="会员收费团可见分部" prop="memberFeeShowOrganId">
  231. <select-all
  232. v-model.trim="form.memberFeeShowOrganId"
  233. filterable
  234. placeholder="请选择所属分部"
  235. style="width: 400px !important"
  236. multiple
  237. :disabled="pageDisabled"
  238. clearable
  239. >
  240. <el-option
  241. v-for="item in selects.branchs"
  242. :key="item.id"
  243. :label="item.name"
  244. :value="item.id.toString()"
  245. ></el-option>
  246. </select-all>
  247. </el-form-item>
  248. <el-form-item label="参与置换可见分部" prop="replacementShowOrganId">
  249. <select-all
  250. v-model.trim="form.replacementShowOrganId"
  251. filterable
  252. placeholder="请选择所属分部"
  253. style="width: 400px !important"
  254. multiple
  255. :disabled="pageDisabled"
  256. clearable
  257. >
  258. <el-option
  259. v-for="item in selects.branchs"
  260. :key="item.id"
  261. :label="item.name"
  262. :value="item.id.toString()"
  263. ></el-option>
  264. </select-all>
  265. </el-form-item>
  266. <!-- <el-form-item label="学员是否展示" prop="clientShow">
  267. <el-select
  268. v-model="form.clientShow"
  269. :disabled="pageDisabled"
  270. placeholder="请选择学员是否展示"
  271. style="width: 220px !important"
  272. >
  273. <el-option label="是" :value="1"></el-option>
  274. <el-option label="否" :value="0"></el-option>
  275. </el-select>
  276. </el-form-item> -->
  277. <!-- <el-form-item label="管理端是否展示" prop="educationalShow">
  278. <el-select
  279. v-model="form.educationalShow"
  280. placeholder="请选择教务端是否展示"
  281. :disabled="pageDisabled"
  282. style="width: 220px !important"
  283. >
  284. <el-option label="是" :value="1"></el-option>
  285. <el-option label="否" :value="0"></el-option>
  286. </el-select>
  287. </el-form-item> -->
  288. <!-- <el-form-item label="乐团是否展示" prop="musicGroupShow">
  289. <el-select
  290. v-model="form.musicGroupShow"
  291. :disabled="pageDisabled"
  292. placeholder="请选择乐团是否展示"
  293. style="width: 220px !important"
  294. >
  295. <el-option label="是" :value="1"></el-option>
  296. <el-option label="否" :value="0"></el-option>
  297. </el-select>
  298. </el-form-item> -->
  299. <!-- <el-form-item label="乐团收费模式" prop="courseViewType">
  300. <select-all
  301. v-model.trim="form.courseViewType"
  302. filterable
  303. placeholder="请选择乐团收费模式"
  304. style="width: 220px !important"
  305. multiple
  306. :disabled="
  307. pageDisabled ||
  308. (form.musicGroupShow != 0 && form.musicGroupShow != 1)
  309. "
  310. clearable
  311. >
  312. <el-option label="课程收费" value="0"></el-option>
  313. <el-option label="系统收费" value="1"></el-option>
  314. <el-option label="云教练收费" value="2"></el-option>
  315. </select-all>
  316. </el-form-item> -->
  317. <!-- <el-form-item label="是否参与置换" prop="replacementShow">
  318. <el-select
  319. v-model="form.replacementShow"
  320. placeholder="请选择库存预警"
  321. :disabled="pageDisabled"
  322. style="width: 220px !important"
  323. >
  324. <el-option label="是" :value="1"></el-option>
  325. <el-option label="否" :value="0"></el-option>
  326. </el-select>
  327. </el-form-item> -->
  328. <el-alert
  329. title="商品信息"
  330. :closable="false"
  331. class="alert"
  332. type="info"
  333. />
  334. <el-form-item label="商品图片" prop="image">
  335. <el-upload
  336. class="avatar-uploader"
  337. action="/api-web/uploadFile"
  338. accept=".jpg, .jpeg, .png"
  339. :headers="headers"
  340. :disabled="pageDisabled"
  341. :show-file-list="false"
  342. :on-success="handleAvatarSuccess"
  343. :before-upload="beforeAvatarUpload"
  344. >
  345. <img v-if="form.image" :src="form.image" class="avatar" />
  346. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  347. </el-upload>
  348. </el-form-item>
  349. <br />
  350. <el-form-item label="商品描述" prop="brief">
  351. <el-input
  352. type="textarea"
  353. v-model.trim="form.brief"
  354. :disabled="pageDisabled"
  355. style="width: 400px"
  356. ></el-input>
  357. </el-form-item>
  358. <br />
  359. <el-form-item label="商品详情" prop="desc">
  360. <el-input
  361. type="textarea"
  362. v-model.trim="form.desc"
  363. :disabled="pageDisabled"
  364. style="width: 400px"
  365. ></el-input>
  366. </el-form-item>
  367. <br />
  368. <el-form-item v-if="!pageDisabled">
  369. <el-button @click="onSubmit('form')" type="primary">保存</el-button>
  370. <el-button @click="onReSet('form')">重置</el-button>
  371. </el-form-item>
  372. </el-form>
  373. </div>
  374. </div>
  375. </template>
  376. <script>
  377. import {
  378. categoryListTree,
  379. goodsAdd,
  380. goodsUpdate,
  381. goodsSingleQuery,
  382. } from "@/api/businessManager";
  383. import { getToken } from "@/utils/auth";
  384. import { goodsType, stockType } from "@/utils/searchArray";
  385. let validPrice = (rule, value, callback) => {
  386. if ((value == "" && typeof value == "string") || value == null) {
  387. callback(new Error("请输入金额"));
  388. } else if (value < 0) {
  389. callback(new Error("输入金额必须大于或等于0"));
  390. } else if (value >= 100000) {
  391. callback(new Error("输入金额必须小于100000"));
  392. } else {
  393. callback();
  394. }
  395. };
  396. let validStock = (rule, value, callback) => {
  397. if ((value == "" && typeof value == "string") || value == null) {
  398. callback(new Error("请输入库存"));
  399. } else if (value < 0) {
  400. callback(new Error("库存数量必须大于或等于0"));
  401. } else {
  402. callback();
  403. }
  404. };
  405. export default {
  406. name: "shopOperation",
  407. data() {
  408. return {
  409. goodsType: goodsType,
  410. stockType: stockType,
  411. categoryList: [],
  412. pageType: null,
  413. pageTitle: {
  414. create: "添加",
  415. update: "修改",
  416. look: "查看",
  417. copy: "复制",
  418. },
  419. pageDisabled: false,
  420. headers: {
  421. Authorization: getToken(),
  422. },
  423. form: {
  424. sn: null,
  425. brand: null,
  426. supplyChannel: null,
  427. name: null,
  428. type: null,
  429. goodsCategoryId: null,
  430. // organIdList: [],
  431. specification: null,
  432. stockCount: null,
  433. taxStockCount: null,
  434. stockType: null,
  435. marketPrice: null,
  436. discountPrice: null,
  437. groupPurchasePrice: null,
  438. clientShow: null,
  439. educationalShow: null,
  440. musicGroupShow: null,
  441. courseViewType: [],
  442. stockWarning: null,
  443. image: null,
  444. brief: null,
  445. desc: null,
  446. replacementShow: null,
  447. studentShowOrganId: null,
  448. educationShowOrganId: null,
  449. courseFeeShowOrganId: null,
  450. memberFeeShowOrganId: null,
  451. replacementShowOrganId: null,
  452. },
  453. rules: {
  454. sn: [{ required: true, message: "请输入商品货号", trigger: "blur" }],
  455. brand: [
  456. {
  457. required: true,
  458. message: "请输入品牌",
  459. trigger: "blur",
  460. },
  461. {
  462. min: 2,
  463. max: 30,
  464. message: "长度在 2 到 30 个字符",
  465. trigger: "blur",
  466. },
  467. ],
  468. supplyChannel: [
  469. { required: true, message: "请输入备查货号", trigger: "blur" },
  470. ],
  471. name: [
  472. {
  473. required: true,
  474. message: "请输入商品名称",
  475. trigger: "blur",
  476. },
  477. {
  478. min: 2,
  479. max: 30,
  480. message: "长度在 2 到 30 个字符",
  481. trigger: "blur",
  482. },
  483. ],
  484. type: [
  485. {
  486. required: true,
  487. message: "请选择商品分类",
  488. trigger: "change",
  489. },
  490. ],
  491. goodsCategoryId: [
  492. {
  493. required: true,
  494. message: "请选择商品类型",
  495. trigger: "change",
  496. },
  497. ],
  498. organIdList: [
  499. {
  500. required: true,
  501. message: "请选择所属分部",
  502. trigger: "change",
  503. },
  504. ],
  505. specification: [
  506. {
  507. required: true,
  508. message: "请输入商品型号",
  509. trigger: "blur",
  510. },
  511. {
  512. min: 2,
  513. max: 30,
  514. message: "长度在 2 到 30 个字符",
  515. trigger: "blur",
  516. },
  517. ],
  518. stockCount: [
  519. { required: true, validator: validStock, trigger: "blur" },
  520. ],
  521. taxStockCount: [
  522. { required: true, validator: validStock, trigger: "blur" },
  523. ],
  524. stockType: [
  525. { required: true, message: "请选择库存类型", trigger: "change" },
  526. ],
  527. marketPrice: [
  528. {
  529. required: true,
  530. validator: validPrice,
  531. trigger: "blur",
  532. },
  533. ],
  534. discountPrice: [
  535. {
  536. required: true,
  537. validator: validPrice,
  538. trigger: "blur",
  539. },
  540. ],
  541. groupPurchasePrice: [
  542. {
  543. required: true,
  544. validator: validPrice,
  545. trigger: "blur",
  546. },
  547. ],
  548. clientShow: [
  549. { required: true, message: "请选择学员是否展示", trigger: "change" },
  550. ],
  551. replacementShow: [
  552. { required: true, message: "是否参与乐器置换", trigger: "change" },
  553. ],
  554. educationalShow: [
  555. {
  556. required: true,
  557. message: "请选择教务端是否展示",
  558. trigger: "change",
  559. },
  560. ],
  561. musicGroupShow: [
  562. { required: true, message: "请选择乐团是否展示", trigger: "change" },
  563. ],
  564. courseViewType: [
  565. { required: true, message: "请选乐团收费模式", trigger: "change" },
  566. ],
  567. stockWarning: [
  568. { required: true, message: "请选择是否库存预警", trigger: "change" },
  569. ],
  570. image: [
  571. {
  572. required: true,
  573. message: "请选择图片",
  574. trigger: "blur",
  575. },
  576. ],
  577. brief: [
  578. {
  579. required: true,
  580. message: "请输入商品描述",
  581. trigger: "blur",
  582. },
  583. ],
  584. desc: [
  585. {
  586. required: true,
  587. message: "请输入商品详情",
  588. trigger: "blur",
  589. },
  590. ],
  591. },
  592. Fsearch: null,
  593. Frules: null,
  594. imageWidthM: 400,
  595. imageHeightM: 400,
  596. };
  597. },
  598. mounted() {
  599. // 获取分部
  600. this.$store.dispatch("setBranchs");
  601. this.init();
  602. },
  603. methods: {
  604. init() {
  605. let query = this.$route.query;
  606. if (query.paramInfo) {
  607. let paramInfo = JSON.parse(query.paramInfo);
  608. this.pageType = paramInfo.type;
  609. this.id = paramInfo.id;
  610. }
  611. this.pageDisabled = this.pageType == "look" ? true : false;
  612. this.getList();
  613. this.getCatagory();
  614. },
  615. onSubmit(formName) {
  616. this.$refs[formName].validate((valid) => {
  617. if (valid) {
  618. let tempForm = JSON.parse(JSON.stringify(this.form));
  619. if (tempForm.courseViewType) {
  620. tempForm.courseViewType = tempForm.courseViewType.join(",");
  621. }
  622. // if (tempForm.organIdList) {
  623. // tempForm.organIdList = tempForm.organIdList.join(",");
  624. // }
  625. if (tempForm.studentShowOrganId) {
  626. tempForm.studentShowOrganId = tempForm.studentShowOrganId.join(",");
  627. }
  628. if (tempForm.educationShowOrganId) {
  629. tempForm.educationShowOrganId =
  630. tempForm.educationShowOrganId.join(",");
  631. }
  632. if (tempForm.courseFeeShowOrganId) {
  633. tempForm.courseFeeShowOrganId =
  634. tempForm.courseFeeShowOrganId.join(",");
  635. }
  636. if (tempForm.memberFeeShowOrganId) {
  637. tempForm.memberFeeShowOrganId =
  638. tempForm.memberFeeShowOrganId.join(",");
  639. }
  640. if (tempForm.replacementShowOrganId) {
  641. tempForm.replacementShowOrganId =
  642. tempForm.replacementShowOrganId.join(",");
  643. }
  644. if(!tempForm.studentShowOrganId&&!tempForm.educationShowOrganId&&!tempForm.courseFeeShowOrganId&&!tempForm.memberFeeShowOrganId&&!tempForm.replacementShowOrganId){
  645. this.$message.error('请至少选择一个可见分部')
  646. return
  647. }
  648. if (this.pageType == "create" || this.pageType == "copy") {
  649. if (tempForm.id) {
  650. // 判断有没有Id,如果有则删除
  651. delete tempForm.id;
  652. }
  653. tempForm.status = "NO"; // 默认上架
  654. goodsAdd(tempForm).then((res) => {
  655. this.messageTips("保存", res);
  656. });
  657. } else if (this.pageType == "update") {
  658. goodsUpdate(tempForm).then((res) => {
  659. this.messageTips("保存", res);
  660. });
  661. }
  662. } else {
  663. this.$nextTick(() => {
  664. let isError = document.getElementsByClassName("is-error");
  665. isError[0].scrollIntoView({
  666. block: "center",
  667. behavior: "smooth",
  668. });
  669. });
  670. return false;
  671. }
  672. });
  673. },
  674. messageTips(title, res) {
  675. if (res.code == 200) {
  676. this.$message.success(title + "成功");
  677. this.$store.dispatch("delVisitedViews", this.$route);
  678. this.$router.push({
  679. path: "/shopList",
  680. query: {
  681. pageInfo: this.Frules,
  682. searchForm: this.Fsearch,
  683. },
  684. });
  685. } else {
  686. this.$message.error(res.msg);
  687. }
  688. },
  689. onCancel() {
  690. this.$store.dispatch("delVisitedViews", this.$route);
  691. this.$router.push({
  692. path: "/shopList",
  693. });
  694. },
  695. onReSet(formName) {
  696. this.$refs[formName].resetFields();
  697. },
  698. getList() {
  699. if (this.pageType == "create") {
  700. this.form = {
  701. sn: null,
  702. brand: null,
  703. supplyChannel: null,
  704. name: null,
  705. type: null,
  706. goodsCategoryId: null,
  707. organIdList: [],
  708. specification: null,
  709. stockCount: null,
  710. taxStockCount: null,
  711. stockType: null,
  712. marketPrice: null,
  713. discountPrice: null,
  714. groupPurchasePrice: null,
  715. clientShow: null,
  716. educationalShow: null,
  717. musicGroupShow: null,
  718. courseViewType: [],
  719. stockWarning: null,
  720. image: null,
  721. brief: null,
  722. desc: null,
  723. };
  724. if (this.$refs["form"]) {
  725. this.$refs["form"].resetFields();
  726. }
  727. } else {
  728. goodsSingleQuery(this.id).then((res) => {
  729. if (res.code == 200) {
  730. let result = res.data;
  731. let courseViewType = null;
  732. if (result.courseViewType) {
  733. courseViewType = result.courseViewType.split(",");
  734. }
  735. // let organIdList = [];
  736. // if (result.organIdList) {
  737. // organIdList = result.organIdList.split(",");
  738. // }
  739. let studentShowOrganId = [];
  740. if (result.studentShowOrganId) {
  741. studentShowOrganId = result.studentShowOrganId.split(",");
  742. }
  743. let educationShowOrganId = [];
  744. if (result.educationShowOrganId) {
  745. educationShowOrganId = result.educationShowOrganId.split(",");
  746. }
  747. let courseFeeShowOrganId = [];
  748. if (result.courseFeeShowOrganId) {
  749. courseFeeShowOrganId = result.courseFeeShowOrganId.split(",");
  750. }
  751. let memberFeeShowOrganId = [];
  752. if (result.memberFeeShowOrganId) {
  753. memberFeeShowOrganId = result.memberFeeShowOrganId.split(",");
  754. }
  755. let replacementShowOrganId = [];
  756. if (result.replacementShowOrganId) {
  757. replacementShowOrganId = result.replacementShowOrganId.split(",");
  758. }
  759. /**studentShowOrganId: 1,2
  760. educationShowOrganId: 2,3
  761. courseFeeShowOrganId: 3,4
  762. memberFeeShowOrganId: 4,5
  763. replacementShowOrganId: 6,7 */
  764. this.form = {
  765. id: result.id,
  766. sn: result.sn,
  767. brand: result.brand,
  768. supplyChannel: result.supplyChannel,
  769. name: result.name,
  770. type: result.type,
  771. goodsCategoryId: result.goodsCategoryId,
  772. // organIdList: organIdList,
  773. studentShowOrganId,
  774. educationShowOrganId,
  775. courseFeeShowOrganId,
  776. memberFeeShowOrganId,
  777. replacementShowOrganId,
  778. specification: result.specification,
  779. stockCount: result.stockCount,
  780. taxStockCount: result.taxStockCount,
  781. stockType: result.stockType,
  782. marketPrice: result.marketPrice,
  783. discountPrice: result.discountPrice,
  784. groupPurchasePrice: result.groupPurchasePrice,
  785. clientShow: result.clientShow,
  786. educationalShow: result.educationalShow,
  787. musicGroupShow: result.musicGroupShow,
  788. courseViewType: courseViewType,
  789. stockWarning: result.stockWarning,
  790. image: result.image,
  791. brief: result.brief,
  792. desc: result.desc,
  793. replacementShow: result.replacementShow,
  794. };
  795. }
  796. });
  797. }
  798. },
  799. getCatagory() {
  800. categoryListTree({
  801. delFlag: 0,
  802. rows: 9999,
  803. }).then((res) => {
  804. let result = res.data;
  805. if (res.code == 200) {
  806. let tempArray = [];
  807. result.rows.forEach((row) => {
  808. tempArray.push({
  809. label: row.name,
  810. value: row.id,
  811. });
  812. });
  813. this.categoryList = tempArray;
  814. }
  815. });
  816. },
  817. handleAvatarSuccess(res, file) {
  818. this.form.image = res.data.url;
  819. },
  820. beforeAvatarUpload(file) {
  821. const imageType = {
  822. "image/png": true,
  823. "image/jpeg": true,
  824. };
  825. const isImage = imageType[file.type];
  826. const isLt2M = file.size / 1024 / 1024 < 2;
  827. const imageWidth = this.imageWidthM;
  828. const imageHeigh = this.imageHeightM;
  829. const _URL = window.URL || window.webkitURL;
  830. const isSize = new Promise((resolve, reject) => {
  831. const img = new Image();
  832. img.onload = function () {
  833. if (imageWidth && imageHeigh) {
  834. this.width === imageWidth && this.height === imageHeigh
  835. ? resolve()
  836. : reject(`请上传${imageWidth}x${imageHeigh}尺寸图片`);
  837. } else if (imageWidth && !imageHeigh) {
  838. this.width === imageWidth
  839. ? resolve()
  840. : reject(`请上传宽为${imageWidth}的图片`);
  841. } else if (!imageWidth && imageHeigh) {
  842. this.height === imageHeigh
  843. ? resolve()
  844. : reject(`请上传高为${imageHeigh}的图片`);
  845. } else {
  846. resolve();
  847. }
  848. };
  849. img.src = _URL.createObjectURL(file);
  850. }).then(
  851. () => {
  852. return file;
  853. },
  854. (src) => {
  855. this.$message.error(src);
  856. this.uploadImgLoading = false;
  857. return Promise.reject();
  858. }
  859. );
  860. if (!isImage) {
  861. this.$message.error("只能上传图片格式!");
  862. }
  863. if (!isLt2M) {
  864. this.$message.error("上传头像图片大小不能超过 2MB!");
  865. }
  866. return isImage && isLt2M && isSize;
  867. },
  868. },
  869. };
  870. </script>
  871. <style lang="scss" scoped>
  872. .alert {
  873. margin-bottom: 22px;
  874. }
  875. .el-button--primary {
  876. background: #14928a;
  877. border-color: #14928a;
  878. color: #fff;
  879. &:hover,
  880. &:active,
  881. &:focus {
  882. background: #14928a;
  883. border-color: #14928a;
  884. color: #fff;
  885. }
  886. }
  887. .el-row {
  888. margin-top: 40px;
  889. }
  890. .el-col {
  891. display: flex;
  892. align-items: center;
  893. margin-bottom: 20px;
  894. justify-content: flex-end;
  895. margin-right: 50%;
  896. }
  897. .el-input-group {
  898. width: 200px;
  899. margin: 0 20px;
  900. }
  901. /deep/.el-tree-node__content {
  902. height: 40px !important;
  903. }
  904. /deep/.avatar-uploader .el-upload {
  905. border: 1px dashed #d9d9d9;
  906. border-radius: 6px;
  907. cursor: pointer;
  908. position: relative;
  909. overflow: hidden;
  910. }
  911. .avatar-uploader .el-upload:hover {
  912. border-color: #409eff;
  913. }
  914. .avatar-uploader-icon {
  915. font-size: 28px;
  916. color: #8c939d;
  917. width: 120px;
  918. height: 120px;
  919. line-height: 120px;
  920. text-align: center;
  921. }
  922. .avatar {
  923. width: 120px;
  924. height: 120px;
  925. display: block;
  926. }
  927. .el-select__tags .el-tag.el-tag--info.el-tag--small.el-tag--light {
  928. max-width: 95px;
  929. }
  930. </style>