addEdit.vue 9.6 KB

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