addEdit.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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="online_reason">
  87. <el-input
  88. :disabled="false"
  89. placeholder="上线原因"
  90. v-model="ruleForm.online_reason"
  91. maxlength="200"
  92. />
  93. </el-form-item>
  94. </el-col>
  95. <el-col :span="16" style="text-align: right">
  96. <el-form-item label="上线备注" prop="online_remark">
  97. <el-input
  98. type="textarea"
  99. :rows="3"
  100. :disabled="false"
  101. placeholder="商品备注"
  102. maxlength="2000"
  103. show-word-limit
  104. v-model="ruleForm.online_remark"
  105. />
  106. </el-form-item>
  107. <el-button v-if="id !== '007'" type="primary" :size="'mini'" @click="submitForm">保 存</el-button>
  108. <el-button :size="'mini'" @click="showModelThis = false">
  109. {{
  110. id == "007" ? "关 闭" : "取 消"
  111. }}
  112. </el-button>
  113. </el-col>
  114. </el-row>
  115. </el-form>
  116. </el-col>
  117. </el-row>
  118. </el-card>
  119. </el-dialog>
  120. </template>
  121. <script>
  122. import asyncRequest from "@/apis/service/goodStore/dealGoodsPool";
  123. import resToken from "@/mixins/resToken";
  124. export default {
  125. name: "brand",
  126. props: ["showModel", "id", "sitem"],
  127. mixins: [resToken],
  128. data() {
  129. return {
  130. loading: false,
  131. showModelThis: this.showModel,
  132. ruleForm: {
  133. platform: "", //string 平台id
  134. online_reason: "", //string 上线原因
  135. online_remark: "" //string 上线备注
  136. },
  137. //是否定制
  138. options1: [
  139. { id: "0", name: "否" },
  140. { id: "1", name: "是" }
  141. ],
  142. rulesThis: this.rules,
  143. rules: {
  144. platform: [
  145. {
  146. required: true,
  147. message: "请选择所属平台",
  148. trigger: "change"
  149. }
  150. ],
  151. online_reason: [
  152. {
  153. required: true,
  154. message: "上线原因不能为空",
  155. trigger: "blur"
  156. }
  157. ],
  158. online_remark: [
  159. {
  160. required: true,
  161. message: "上线备注不能为空",
  162. trigger: "blur"
  163. }
  164. ]
  165. }
  166. };
  167. },
  168. watch: {
  169. showModel: function(val) {
  170. this.showModelThis = val;
  171. if (val) {
  172. this.initForm();
  173. }
  174. },
  175. showModelThis(val) {
  176. if (!val) {
  177. this.$emit("cancel");
  178. }
  179. }
  180. },
  181. methods: {
  182. async initForm() {
  183. this.loading = true;
  184. this.rulesThis = this.rules;
  185. await this.resetForm();
  186. this.loading = false;
  187. },
  188. async resetForm() {
  189. // 重置
  190. await this.$nextTick(() => {
  191. if (this.$refs.ruleForm) {
  192. this.$refs.ruleForm.resetFields();
  193. this.$refs.ruleForm.clearValidate();
  194. this.ruleForm = {
  195. platform: "", //string 平台id
  196. online_reason: "", //string 上线原因
  197. online_remark: "" //string 上线备注
  198. };
  199. }
  200. });
  201. },
  202. platform_codesearchChange(e) {
  203. const { id, code, label } = e;
  204. this.ruleForm.platform = id || "";
  205. this.$refs.ruleForm.validateField("platform");
  206. },
  207. async submitForm() {
  208. await this.$refs.ruleForm.validate(async valid => {
  209. if (valid) {
  210. if (!this.loading) {
  211. this.loading = true;
  212. let model = JSON.parse(JSON.stringify(this.ruleForm));
  213. // model.platform = model.platform.toString();
  214. model.codes = [];
  215. let list = JSON.parse(JSON.stringify(this.sitem));
  216. list.forEach(e => {
  217. model.codes.push(e.spuCode);
  218. });
  219. let { code, data, message } = await asyncRequest.online_add(model);
  220. this.loading = false;
  221. if (code === 0) {
  222. this.$notify.success({
  223. title: "已成功添加至上线流程!",
  224. message: ""
  225. });
  226. this.showModelThis = false;
  227. // 刷新
  228. this.$emit("refresh");
  229. } else if (code >= 100 && code <= 104) {
  230. await this.logout();
  231. } else if (code === 1009) {
  232. let resList = JSON.parse(JSON.stringify(data));
  233. let htmlList = "<ul>";
  234. resList.forEach(v => {
  235. htmlList += `<li>
  236. <img src='${v.good_img}' style='width: 20px; height: 20px'
  237. class='hover'
  238. v-viewer/>
  239. <span>${v.good_name}__</span>`;
  240. const { speclist } = v;
  241. let str = "<span>";
  242. speclist.forEach((a, ai) => {
  243. str += `${ai !== 0 ? "--" : ""}${a.spec_name}[${
  244. a.spec_value
  245. }]`;
  246. });
  247. htmlList += str + "</span>" + `</li>`;
  248. });
  249. htmlList += "</ul>";
  250. this.$notify({
  251. title: "以下商品已上线或已经在审批流程中!",
  252. dangerouslyUseHTMLString: true,
  253. message: htmlList
  254. });
  255. } else {
  256. this.$message.warning(message);
  257. }
  258. }
  259. } else {
  260. console.log("error submit!!");
  261. return false;
  262. }
  263. });
  264. }
  265. }
  266. };
  267. </script>
  268. <style lang="scss" scoped>
  269. .brand {
  270. }
  271. </style>