addEdit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <el-dialog
  3. v-loading="loading"
  4. :title="'添加商品上线'"
  5. :center="true"
  6. align="left"
  7. top="8vh"
  8. width="1040px"
  9. :close-on-click-modal="false"
  10. :visible.sync="showModelThis"
  11. element-loading-text="拼命加载中"
  12. element-loading-spinner="el-icon-loading"
  13. element-loading-background="rgba(0, 0, 0, 0.8)"
  14. @close="showModelThis = false"
  15. >
  16. <el-card style="margin: -20px 0 0 0; padding-bottom: 0">
  17. <el-row :gutter="10">
  18. <el-col :span="24" style="padding: 0 0 15px 0">
  19. <el-table
  20. :data="sitem"
  21. stripe
  22. :size="'mini'"
  23. border
  24. max-height="380px"
  25. style="width: 100%"
  26. >
  27. <el-table-column prop="spuCode" label="编号" width="160" show-overflow-tooltip />
  28. <el-table-column prop="good_img" label="图片" width="45" show-overflow-tooltip>
  29. <template slot-scope="scope">
  30. <div
  31. v-if="scope.row.good_img"
  32. style="width: 20px; height: 20px"
  33. class="hover"
  34. v-viewer
  35. >
  36. <img
  37. :src="scope.row.good_img"
  38. style="display: inline-block; width: 100%; height: 100%"
  39. alt
  40. />
  41. </div>
  42. </template>
  43. </el-table-column>
  44. <el-table-column prop="good_name" label="名称" min-width="160px" show-overflow-tooltip />
  45. <el-table-column prop="cat_name" label="分类" min-width="100" show-overflow-tooltip />
  46. <el-table-column prop="brand_name" label="品牌" show-overflow-tooltip />
  47. <el-table-column prop="good_type" label="定制" width="50" show-overflow-tooltip>
  48. <template slot-scope="scope">
  49. <el-tag
  50. :size="'mini'"
  51. :type="scope.row.good_type == '1' ? '' : 'warning'"
  52. v-text="
  53. (options1.find((item) => item.id == scope.row.status) || {})
  54. .name || '--'
  55. "
  56. ></el-tag>
  57. </template>
  58. </el-table-column>
  59. <el-table-column prop="supplierNo" label="供应商编号" width="110" show-overflow-tooltip />
  60. <el-table-column prop="supplier_name" label="供应商名称" width="110" show-overflow-tooltip />
  61. <el-table-column prop="companyNo" label="业务公司编号" width="110" show-overflow-tooltip />
  62. <el-table-column prop="company" label="业务公司名称" width="110" show-overflow-tooltip />
  63. </el-table>
  64. </el-col>
  65. <el-col :span="24">
  66. <el-form
  67. ref="ruleForm"
  68. :model="ruleForm"
  69. status-icon
  70. :rules="rulesThis"
  71. label-width="80px"
  72. class="demo-ruleForm"
  73. >
  74. <el-row style="padding-bottom">
  75. <el-col :span="8">
  76. <el-form-item label="所属平台" prop="platform">
  77. <search-terrace
  78. :value="ruleForm.platform"
  79. :disabled="false"
  80. :isDetail="false"
  81. :is_show="'1'"
  82. :placeholder="'所属平台'"
  83. @searchChange="platform_codesearchChange"
  84. />
  85. </el-form-item>
  86. <el-form-item label="对接平台" prop="platform_type">
  87. <el-select
  88. :disabled="!ruleForm.platform_type"
  89. v-model="ruleForm.platform_type"
  90. @change="ruleForm.platform = ''"
  91. disabled
  92. placeholder="对接平台"
  93. style="width:100%"
  94. >
  95. <el-option label="有赞平台" value="1" />
  96. <el-option label="无对接" value="0" />
  97. </el-select>
  98. </el-form-item>
  99. <el-form-item label="定价模式" prop="is_fixed">
  100. <el-select v-model="ruleForm.is_fixed" style="width:100%">
  101. <el-option
  102. v-for="p in pricingOptions"
  103. :key="p.value"
  104. :value="p.value"
  105. :label="p.label"
  106. />
  107. </el-select>
  108. </el-form-item>
  109. <el-form-item label="上线原因" prop="online_reason">
  110. <el-input
  111. :disabled="false"
  112. placeholder="上线原因"
  113. v-model="ruleForm.online_reason"
  114. maxlength="200"
  115. />
  116. </el-form-item>
  117. </el-col>
  118. <el-col :span="16" style="text-align: right">
  119. <el-form-item label="上线备注" prop="online_remark">
  120. <el-input
  121. type="textarea"
  122. :rows="3"
  123. :disabled="false"
  124. placeholder="商品备注"
  125. maxlength="2000"
  126. show-word-limit
  127. v-model="ruleForm.online_remark"
  128. />
  129. </el-form-item>
  130. <el-button v-if="id !== '007'" type="primary" :size="'mini'" @click="submitForm">保 存</el-button>
  131. <el-button :size="'mini'" @click="showModelThis = false">
  132. {{
  133. id == "007" ? "关 闭" : "取 消"
  134. }}
  135. </el-button>
  136. </el-col>
  137. </el-row>
  138. </el-form>
  139. </el-col>
  140. </el-row>
  141. </el-card>
  142. </el-dialog>
  143. </template>
  144. <script>
  145. import asyncRequest from "@/apis/service/goodStore/dealGoodsPool";
  146. import resToken from "@/mixins/resToken";
  147. export default {
  148. name: "brand",
  149. props: ["showModel", "id", "sitem", "isNobleMetal"],
  150. mixins: [resToken],
  151. data() {
  152. return {
  153. loading: false,
  154. isYZPlatform:false,
  155. showModelThis: this.showModel,
  156. ruleForm: {
  157. platform_type: "",
  158. is_fixed: "",
  159. platform: "", //string 平台id
  160. online_reason: "", //string 上线原因
  161. online_remark: "" //string 上线备注
  162. },
  163. //是否定制
  164. options1: [
  165. { id: "0", name: "否" },
  166. { id: "1", name: "是" }
  167. ],
  168. rulesThis: this.rules,
  169. rules: {
  170. is_fixed: [
  171. {
  172. required: true,
  173. message: "请选择定价模式",
  174. trigger: "change"
  175. }
  176. ],
  177. platform_type: [
  178. {
  179. required: true,
  180. message: "请选择对接平台",
  181. trigger: "change"
  182. }
  183. ],
  184. platform: [
  185. {
  186. required: true,
  187. message: "请选择所属平台",
  188. trigger: "change"
  189. }
  190. ],
  191. online_reason: [
  192. {
  193. required: true,
  194. message: "上线原因不能为空",
  195. trigger: "blur"
  196. }
  197. ],
  198. online_remark: [
  199. {
  200. required: true,
  201. message: "上线备注不能为空",
  202. trigger: "blur"
  203. }
  204. ]
  205. }
  206. };
  207. },
  208. watch: {
  209. isFiexed() {
  210. if (this.ruleForm.is_fixed === "0") {
  211. this.ruleForm.is_fixed = "";
  212. }
  213. },
  214. showModel: function(val) {
  215. this.showModelThis = val;
  216. if (val) {
  217. this.initForm();
  218. }
  219. },
  220. showModelThis(val) {
  221. if (!val) {
  222. this.$emit("cancel");
  223. }
  224. }
  225. },
  226. computed:{
  227. isFiexed() {
  228. return (
  229. !this.isYZPlatform &&
  230. this.isNobleMetal &&
  231. this.ruleForm.platform_type !== "1"
  232. );
  233. },
  234. pricingOptions() {
  235. return [
  236. { value: "1", label: "一口价" },
  237. ...(this.isFiexed ? [{ value: "0", label: "实时金价" }] : [])
  238. ];
  239. }
  240. },
  241. methods: {
  242. isFiexed() {
  243. return (
  244. !this.isYZPlatform &&
  245. this.isNobleMetal &&
  246. this.ruleForm.platform_type !== "1"
  247. );
  248. },
  249. pricingOptions() {
  250. return [
  251. { value: "1", label: "一口价" },
  252. ...(this.isFiexed ? [{ value: "0", label: "实时金价" }] : [])
  253. ];
  254. },
  255. async initForm() {
  256. this.loading = true;
  257. this.rulesThis = this.rules;
  258. await this.resetForm();
  259. this.loading = false;
  260. },
  261. async resetForm() {
  262. // 重置
  263. await this.$nextTick(() => {
  264. if (this.$refs.ruleForm) {
  265. this.$refs.ruleForm.resetFields();
  266. this.$refs.ruleForm.clearValidate();
  267. this.ruleForm = {
  268. platform_type:"",
  269. is_fiexed:"",
  270. platform: "", //string 平台id
  271. online_reason: "", //string 上线原因
  272. online_remark: "" //string 上线备注
  273. };
  274. }
  275. });
  276. },
  277. platform_codesearchChange(e) {
  278. const { id, code, label, platform_type } = e;
  279. this.ruleForm.platform = id || "";
  280. this.isYZPlatform = platform_type === "1";
  281. this.ruleForm.platform_type = platform_type
  282. this.$refs.ruleForm.validateField("platform");
  283. },
  284. async submitForm() {
  285. await this.$refs.ruleForm.validate(async valid => {
  286. if (valid) {
  287. if (!this.loading) {
  288. this.loading = true;
  289. let model = JSON.parse(JSON.stringify(this.ruleForm));
  290. // model.platform = model.platform.toString();
  291. model.codes = [];
  292. let list = JSON.parse(JSON.stringify(this.sitem));
  293. list.forEach(e => {
  294. model.codes.push(e.spuCode);
  295. });
  296. let { code, data, message } = await asyncRequest.online_add(model);
  297. this.loading = false;
  298. if (code === 0) {
  299. this.$notify.success({
  300. title: "已成功添加至上线流程!",
  301. message: ""
  302. });
  303. this.showModelThis = false;
  304. // 刷新
  305. this.$emit("refresh");
  306. } else if (code >= 100 && code <= 104) {
  307. await this.logout();
  308. } else if (code === 1009) {
  309. let resList = JSON.parse(JSON.stringify(data));
  310. let htmlList = "<ul>";
  311. resList.forEach(v => {
  312. htmlList += `<li>
  313. <img src='${v.good_img}' style='width: 20px; height: 20px'
  314. class='hover'
  315. v-viewer/>
  316. <span>${v.good_name}__</span>`;
  317. const { speclist } = v;
  318. let str = "<span>";
  319. speclist.forEach((a, ai) => {
  320. str += `${ai !== 0 ? "--" : ""}${a.spec_name}[${
  321. a.spec_value
  322. }]`;
  323. });
  324. htmlList += str + "</span>" + `</li>`;
  325. });
  326. htmlList += "</ul>";
  327. this.$notify({
  328. title: "以下商品已上线或已经在审批流程中!",
  329. dangerouslyUseHTMLString: true,
  330. message: htmlList
  331. });
  332. } else {
  333. this.$message.warning(message);
  334. }
  335. }
  336. } else {
  337. console.log("error submit!!");
  338. return false;
  339. }
  340. });
  341. }
  342. }
  343. };
  344. </script>
  345. <style lang="scss" scoped>
  346. .brand {
  347. }
  348. </style>