index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <div id="">
  3. <el-dialog
  4. :visible.sync="dialogVisible"
  5. width="1088px"
  6. :show-close="false"
  7. :close-on-click-modal="false"
  8. destroy-on-close
  9. @closed="close"
  10. >
  11. <div slot="title" class="hearders">
  12. <div class="leftTitle">选择商品</div>
  13. <div class="rightBoxs">
  14. <img
  15. src="@/assets/images/Close@2x.png"
  16. alt=""
  17. @click="dialogVisible = false"
  18. />
  19. </div>
  20. </div>
  21. <search-box-new
  22. ref="searchBox"
  23. :formData="formData"
  24. :formList="formList"
  25. @search="search"
  26. @init="search(2)"
  27. :topType="topType"
  28. />
  29. <el-table
  30. ref="table"
  31. row-key="goodsId"
  32. :data="tableData"
  33. v-loading="loading"
  34. border
  35. style="width: 100%"
  36. @selection-change="selectionChange"
  37. >
  38. <el-table-column
  39. type="selection"
  40. width="55"
  41. align="center"
  42. reserve-selection
  43. :selectable="dis_active"
  44. >
  45. </el-table-column>
  46. <el-table-column
  47. align="center"
  48. type="index"
  49. :disabled="true"
  50. ></el-table-column>
  51. <template v-for="(item, index) in tableSet">
  52. <el-table-column
  53. header-align="center"
  54. :align="item.align ? item.align : 'center'"
  55. :prop="item.prop"
  56. :label="item.label"
  57. :width="item.width || ''"
  58. ><template slot-scope="scope"
  59. ><div v-if="item.scope === 'options'">
  60. <template v-for="(itemt, indext) in item.options">
  61. <span v-if="itemt.value === scope.row[item.prop]">{{
  62. itemt.label
  63. }}</span>
  64. </template>
  65. </div>
  66. <span v-else-if="item.scope === 'leftCh'"
  67. >{{ item.ch }}{{ scope.row[item.prop] }}</span
  68. >
  69. <span v-else>{{ scope.row[item.prop] }}</span></template
  70. >
  71. </el-table-column>
  72. </template>
  73. </el-table>
  74. <div style="margin-top: 10px; text-align: center">
  75. <el-pagination
  76. @size-change="handleSizeChange"
  77. @current-change="handleCurrentChange"
  78. :current-page="formData.pageNum"
  79. :page-sizes="[10, 20, 50, 100]"
  80. :page-size="formData.pageSize"
  81. layout="total, sizes, prev, pager, next, jumper"
  82. :total="total"
  83. >
  84. </el-pagination>
  85. </div>
  86. <span slot="footer" class="dialog-footer">
  87. <el-button @click="dialogVisible = false">取 消</el-button>
  88. <el-button type="primary" @click="submitTable" :loading="disbtn"
  89. >确 定</el-button
  90. >
  91. </span>
  92. </el-dialog>
  93. </div>
  94. </template>
  95. <script>
  96. import searchBoxNew from "@/components/searchBoxNew";
  97. export default {
  98. components: { searchBoxNew },
  99. data() {
  100. return {
  101. topType: true,
  102. disbtn: false,
  103. dialogVisible: false,
  104. //搜索
  105. formList: [
  106. {
  107. prop: "educationTypeId",
  108. placeholder: "教育类型",
  109. scope: "educationType",
  110. },
  111. {
  112. prop: "businessId",
  113. placeholder: "业务层次",
  114. scope: "businessLevel",
  115. edu: "educationTypeId",
  116. },
  117. {
  118. prop: "schoolId",
  119. placeholder: "院校",
  120. scope: "schoolList",
  121. edu: "educationTypeId",
  122. },
  123. {
  124. prop: "majorId",
  125. placeholder: "专业",
  126. scope: "Professional",
  127. edu: "educationTypeId",
  128. },
  129. {
  130. prop: "subjectId",
  131. placeholder: "科目",
  132. scope: "sujectType",
  133. edu: "educationTypeId",
  134. },
  135. {
  136. prop: "status",
  137. placeholder: "商品状态",
  138. scope: "select",
  139. noClear: false,
  140. options: [
  141. {
  142. label: "全部状态",
  143. value: "0,1",
  144. },
  145. {
  146. label: "有效",
  147. value: 1,
  148. },
  149. {
  150. label: "无效",
  151. value: 0,
  152. },
  153. ],
  154. },
  155. {
  156. prop: "goodsStatus",
  157. placeholder: "前台可售状态",
  158. scope: "select",
  159. options: [
  160. {
  161. label: "已上架",
  162. value: 1,
  163. },
  164. {
  165. label: "未上架",
  166. value: 0,
  167. },
  168. ],
  169. },
  170. {
  171. prop1: "validityStartTime",
  172. prop2: "validityEndTime",
  173. placeholder1: "商品有效期开始时间",
  174. placeholder2: "商品有效期结束时间",
  175. scope: "moreDataPicker",
  176. },
  177. // {
  178. // prop: "orderGoodsStatus",
  179. // placeholder: "退款状态",
  180. // scope: "select",
  181. // options: [
  182. // {
  183. // label: "已退款",
  184. // value: 1,
  185. // },
  186. // {
  187. // label: "退款中",
  188. // value: 2,
  189. // },
  190. // {
  191. // label: "拒绝退款",
  192. // value: 3,
  193. // },
  194. // ],
  195. // },
  196. {
  197. prop: "goodsName",
  198. placeholder: "请输入商品名称",
  199. },
  200. ],
  201. formData: {
  202. goodsType: "",
  203. status: "0,1",
  204. pageSize: 10,
  205. pageNum: 1,
  206. },
  207. // 表单
  208. tableSet: [
  209. {
  210. label: "商品名称",
  211. prop: "goodsName",
  212. hidden: true,
  213. },
  214. {
  215. label: "商品编码",
  216. prop: "code",
  217. hidden: true,
  218. },
  219. {
  220. label: "科目",
  221. prop: "subjectNames",
  222. hidden: true,
  223. },
  224. {
  225. label: "学时",
  226. prop: "classHours",
  227. hidden: true,
  228. },
  229. {
  230. label: "商品价格",
  231. prop: "standPrice",
  232. hidden: true,
  233. scope: "leftCh",
  234. ch: "¥",
  235. },
  236. {
  237. label: "商品划线价",
  238. prop: "linePrice",
  239. hidden: true,
  240. scope: "leftCh",
  241. ch: "¥",
  242. },
  243. {
  244. label: "可售状态",
  245. prop: "goodsStatus",
  246. hidden: true,
  247. scope: "options",
  248. options: [
  249. {
  250. label: "正常",
  251. value: 1,
  252. },
  253. {
  254. label: "关闭",
  255. value: 0,
  256. },
  257. ],
  258. },
  259. ],
  260. tableData: [],
  261. loading: false,
  262. total: 0,
  263. outActive: [], //置灰列表
  264. active: [], //当前选中
  265. };
  266. },
  267. methods: {
  268. selectionChange(e) {
  269. this.active = e;
  270. },
  271. showBox(e) {
  272. if (e && e.length > 0) {
  273. this.outActive = e;
  274. }
  275. this.search(2);
  276. this.dialogVisible = true;
  277. },
  278. dis_active(e) {
  279. return this.outActive.includes(e.goodsId) ? false : true;
  280. },
  281. search(int) {
  282. if (int === 2) {
  283. this.formData = {
  284. pageSize: 10,
  285. pageNum: 1,
  286. goodsType: "",
  287. status: "0,1",
  288. };
  289. }
  290. if (int === 3) {
  291. this.formData.pageNum = 1;
  292. }
  293. var data = JSON.parse(JSON.stringify(this.formData));
  294. if (this.formData.validityStartTime) {
  295. data.validityStartTime = data.validityStartTime / 1000;
  296. }
  297. if (this.formData.validityEndTime) {
  298. data.validityEndTime = data.validityEndTime / 1000;
  299. }
  300. this.loading = true;
  301. this.$api
  302. .inquireGoods(data)
  303. .then((res) => {
  304. this.tableData = res.rows;
  305. this.total = res.total;
  306. })
  307. .finally(() => {
  308. this.loading = false;
  309. });
  310. },
  311. submitTable() {
  312. if (this.active.length === 0) {
  313. this.$message.warning("请勾选商品");
  314. return;
  315. }
  316. this.disbtn = true;
  317. const array = this.active.map((item) => {
  318. return {
  319. goodsId: item.goodsId,
  320. goodsName: item.goodsName,
  321. goodsPrice: item.standPrice,
  322. profitMax: "",
  323. profitType: 1,
  324. profitOne: "",
  325. profitTwo: "",
  326. profitThree: "",
  327. };
  328. });
  329. this.dialogVisible = false;
  330. this.$emit("backGoodsList", array);
  331. },
  332. close() {
  333. this.disbtn = false;
  334. this.$refs.table.clearSelection();
  335. this.outActive = [];
  336. this.active = [];
  337. },
  338. handleSizeChange(e) {
  339. this.formData.pageSize = e;
  340. this.formData.pageNum = 1;
  341. this.search();
  342. },
  343. handleCurrentChange(e) {
  344. this.formData.pageNum = e;
  345. this.search();
  346. },
  347. },
  348. };
  349. </script>
  350. <style lang="scss" scoped></style>