add.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <div class="activeAdd pagePadding">
  3. <div
  4. v-if="powers && powers.length > 0 && powers.some((item) => item == '007')"
  5. >
  6. <el-form
  7. :model="ruleForm"
  8. status-icon
  9. :rules="rulesThis"
  10. ref="ruleForm"
  11. :size="'mini'"
  12. label-width="110px"
  13. class="demo-ruleForm"
  14. >
  15. <el-row>
  16. <el-col :span="16">
  17. <el-form-item label="活动标题" prop="activity_name">
  18. <el-input
  19. placeholder="活动标题"
  20. v-model="ruleForm.activity_name"
  21. maxlength="100"
  22. />
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="8">
  26. <el-form-item label="业务企业" prop="platform_code1">
  27. <search-work-company
  28. :value="ruleForm.platform_code1"
  29. :disabled="false"
  30. :size="'mini'"
  31. :isDetail="false"
  32. :placeholder="'业务企业'"
  33. @searchChange="platform_codesearchChange"
  34. />
  35. </el-form-item>
  36. </el-col>
  37. <el-col :span="16">
  38. <el-form-item label="活动时间" required style="margin: 0">
  39. <el-row>
  40. <el-col :span="11">
  41. <el-form-item prop="datactivity_name">
  42. <el-date-picker
  43. type="datetime"
  44. placeholder="开始时间"
  45. v-model="ruleForm.activity_start"
  46. style="width: 100%"
  47. ></el-date-picker>
  48. </el-form-item>
  49. </el-col>
  50. <el-col class="tc" :span="2">-</el-col>
  51. <el-col :span="11">
  52. <el-form-item prop="activity_end">
  53. <el-date-picker
  54. type="datetime"
  55. placeholder="结束时间"
  56. v-model="ruleForm.activity_end"
  57. style="width: 100%"
  58. ></el-date-picker>
  59. </el-form-item>
  60. </el-col>
  61. </el-row>
  62. </el-form-item>
  63. </el-col>
  64. <el-col :span="8">
  65. <el-form-item label="所属平台" prop="platform_code">
  66. <search-terrace
  67. :value="ruleForm.platform_code"
  68. :disabled="false"
  69. :size="'mini'"
  70. :isDetail="false"
  71. :placeholder="'所属平台'"
  72. @searchChange="platform_codesearchChange"
  73. />
  74. </el-form-item>
  75. </el-col>
  76. <el-col :span="16">
  77. <el-form-item label="活动描述" prop="activity_desc">
  78. <el-input
  79. placeholder="活动描述"
  80. type="textarea"
  81. :rows="2"
  82. show-word-limit
  83. v-model="ruleForm.activity_desc"
  84. maxlength="500"
  85. />
  86. </el-form-item>
  87. </el-col>
  88. <el-col :span="8">
  89. <el-form-item label="库存类型" prop="is_stock">
  90. <el-input
  91. placeholder="商品库存类型"
  92. v-model="ruleForm.is_stock"
  93. maxlength="100"
  94. />
  95. </el-form-item>
  96. </el-col>
  97. <el-col :span="24">
  98. <el-form-item
  99. label="活动商品"
  100. :label-position="'top'"
  101. prop="good_list"
  102. >
  103. <el-table
  104. :data="ruleForm.spuCode"
  105. stripe
  106. border
  107. :size="'mini'"
  108. style="width: 100%"
  109. >
  110. <el-table-column prop="date" label="日期" width="180">
  111. </el-table-column>
  112. <el-table-column prop="name" label="姓名" width="180">
  113. </el-table-column>
  114. <el-table-column prop="address" label="地址"> </el-table-column>
  115. <el-table-column fixed="right" width="100">
  116. <template slot="header" slot-scope="scope">
  117. <span>操作</span>
  118. <el-tooltip
  119. class="item"
  120. effect="dark"
  121. content="添加活动商品"
  122. placement="top"
  123. >
  124. <i
  125. class="el-icon-circle-plus-outline fr"
  126. style="font-size: 18px; margin-top: 2px"
  127. @click="openEdit('add', '0')"
  128. />
  129. </el-tooltip>
  130. </template>
  131. <template slot-scope="scope">
  132. <el-button
  133. @click="handleClick(scope.row)"
  134. type="text"
  135. size="small"
  136. >查看</el-button
  137. >
  138. <el-button type="text" size="small">编辑</el-button>
  139. </template>
  140. </el-table-column>
  141. </el-table>
  142. </el-form-item>
  143. </el-col>
  144. </el-row>
  145. </el-form>
  146. <search-good-online-modal :once="once" :show-model="showModel" />
  147. </div>
  148. <div v-else>
  149. <no-auth></no-auth>
  150. </div>
  151. </div>
  152. </template>
  153. <script>
  154. import asyncRequest from "@/apis/service/goodStore/active";
  155. import resToken from "@/mixins/resToken";
  156. import { mapGetters } from "vuex";
  157. import searchGoodOnlineModal from "@/components/search-good-online-modal";
  158. export default {
  159. name: "activeAdd",
  160. mixins: [resToken],
  161. components: {
  162. searchGoodOnlineModal,
  163. },
  164. computed: {
  165. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  166. powers() {
  167. let tran =
  168. this.$store.getters.btnList.find(
  169. (item) => item.menu_route == "activeAdd"
  170. ) || {};
  171. if (tran && tran.action && tran.action.length > 0) {
  172. return tran.action;
  173. } else {
  174. return [];
  175. }
  176. },
  177. },
  178. data() {
  179. return {
  180. size: "small",
  181. activeName: "3",
  182. loading: false,
  183. showModel: false,
  184. once: false,
  185. rulesThis: this.rules,
  186. ruleForm: {},
  187. rules: {
  188. activity_name: [
  189. {
  190. required: true,
  191. message: "活动标题不能为空",
  192. trigger: "blur",
  193. },
  194. ],
  195. platform_code1: [
  196. {
  197. type: "array",
  198. required: true,
  199. message: "业务公司不能为空",
  200. trigger: "change",
  201. },
  202. ],
  203. platform_code: [
  204. {
  205. type: "array",
  206. required: true,
  207. message: "所属平台不能为空",
  208. trigger: "change",
  209. },
  210. ],
  211. activity_start: [
  212. {
  213. required: true,
  214. message: "开始时间不能为空",
  215. trigger: "change",
  216. },
  217. ],
  218. activity_end: [
  219. {
  220. required: true,
  221. message: "结束时间不能为空",
  222. trigger: "change",
  223. },
  224. ],
  225. activity_desc: [
  226. {
  227. required: true,
  228. message: "活动描述不能为空",
  229. trigger: "blur",
  230. },
  231. ],
  232. is_stock: [
  233. {
  234. required: true,
  235. message: "请选择是否库存品",
  236. trigger: "change",
  237. },
  238. ],
  239. good_list: [
  240. {
  241. type: "array",
  242. required: true,
  243. message: "请选择活动商品",
  244. trigger: "change,blur",
  245. },
  246. ],
  247. },
  248. };
  249. },
  250. mounted() {
  251. this.initForm();
  252. },
  253. methods: {
  254. async initForm() {
  255. this.loading = true;
  256. this.resetFormData();
  257. this.rulesThis = this.rules;
  258. await this.resetForm();
  259. this.loading = false;
  260. },
  261. async resetForm() {
  262. // 重置
  263. await this.$nextTick(async () => {
  264. if (this.$refs.ruleForm) {
  265. this.$refs.ruleForm.resetFields();
  266. this.$refs.ruleForm.clearValidate();
  267. this.resetFormData();
  268. }
  269. });
  270. },
  271. resetFormData() {
  272. this.ruleForm = {
  273. activity_name: "",
  274. platform_code1: [],
  275. platform_code: [],
  276. activity_start: "",
  277. activity_end: "",
  278. activity_desc: "",
  279. is_stock: "",
  280. good_list: [],
  281. };
  282. },
  283. handleClick(row) {
  284. console.log(row);
  285. },
  286. openEdit(type, id) {
  287. this.showModel = true;
  288. console.log(type);
  289. console.log(id);
  290. },
  291. async initData() {
  292. this.loading = true;
  293. let res = await asyncRequest.detail({ id: this.id });
  294. this.loading = false;
  295. if (res.code === 0) {
  296. await this.resetForm(res.data);
  297. }
  298. },
  299. },
  300. };
  301. </script>
  302. <style lang="scss" scoped>
  303. .activeAdd {
  304. .activeAdd-title {
  305. border-top: 1px solid #ebeef5;
  306. span {
  307. height: 50px;
  308. line-height: 50px;
  309. font-family: "微软雅黑", sans-serif;
  310. font-weight: 400;
  311. font-style: normal;
  312. font-size: 16fpx;
  313. text-align: left;
  314. }
  315. }
  316. /deep/ .ddiv {
  317. border-top: 1px solid #dcdfe6;
  318. }
  319. /deep/ .dtitle {
  320. width: 40px;
  321. text-align: center;
  322. height: 100%;
  323. min-height: 100%;
  324. ul {
  325. padding: 20px 0 0 0;
  326. }
  327. }
  328. /deep/ .dmain {
  329. padding: 20px 0 0 0;
  330. width: calc(100% - 40px);
  331. border-left: 1px solid #dcdfe6;
  332. }
  333. }
  334. </style>