OrderSetting.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <template>
  2. <div class="manage-root personnel-create">
  3. <Header />
  4. <div class="manage-root-contain">
  5. <nav-menu
  6. class="manage-root-contain-left"
  7. :activeMenuIndex="activeMenuIndex"
  8. ></nav-menu>
  9. <div class="manage-root-contain-right">
  10. <breadcrumb
  11. :breadcrumbList="breadcrumbList"
  12. class="breadcrumb-box"
  13. ></breadcrumb>
  14. <div class="create-bottom">
  15. <div class="top-box">
  16. <h3>订阅价格管理</h3>
  17. <div class="save-btn">
  18. <el-button size="small" @click="onCancel">取消</el-button>
  19. <el-button
  20. type="primary"
  21. size="small"
  22. @click="onSubmit()"
  23. :loading="loading"
  24. >保存本页</el-button
  25. >
  26. </div>
  27. </div>
  28. <div class="tabs">
  29. <a
  30. :class="[typeValue === 1 ? 'active' : '']"
  31. @click="handleChangeTabs(1)"
  32. >画刊</a
  33. >
  34. <a
  35. :class="[typeValue === item.study_phase ? 'active' : '']"
  36. @click="handleChangeTabs(item.study_phase)"
  37. v-for="item in $studyType"
  38. :key="item.study_phase"
  39. >{{ item.study_phase_name }}</a
  40. >
  41. </div>
  42. <el-table
  43. class="search-table order-table"
  44. :data="tableObj[typeValue]"
  45. border
  46. style="width: 672px"
  47. :key="typeValue"
  48. v-loading="tableLoading"
  49. :max-height="tableHeight"
  50. >
  51. <el-table-column type="index" label="#" width="64">
  52. </el-table-column>
  53. <el-table-column prop="issue_no" label="总期数" width="152">
  54. <template slot-scope="scope">
  55. <el-input
  56. v-model="scope.row.issue_no"
  57. placeholder="输入"
  58. maxlength="20"
  59. ></el-input>
  60. </template>
  61. </el-table-column>
  62. <el-table-column prop="comb_count" label="合刊" width="152">
  63. <template slot-scope="scope">
  64. <el-input
  65. v-model="scope.row.comb_count"
  66. placeholder="1"
  67. maxlength="20"
  68. ></el-input>
  69. </template>
  70. </el-table-column>
  71. <el-table-column prop="shelve_date" label="发行日期" width="152">
  72. <template slot-scope="scope">
  73. <el-date-picker
  74. v-model="scope.row.shelve_date"
  75. prefix-icon="-"
  76. type="date"
  77. placeholder="选择日期"
  78. value-format="yyyy-MM-dd"
  79. format="yyyy-MM-dd"
  80. >
  81. </el-date-picker>
  82. </template>
  83. </el-table-column>
  84. <el-table-column prop="price" label="价格" width="152">
  85. <template slot-scope="scope">
  86. <el-input
  87. v-model="scope.row.price"
  88. placeholder="输入"
  89. type="number"
  90. @blur="handlePrice(scope.row)"
  91. maxlength="10"
  92. ></el-input>
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. <span class="quick-btn" @click="tableLength('-')"> 减一行 </span>
  97. <span class="quick-btn" @click="tableLength('1')"> 加一行 </span>
  98. <span class="quick-btn" @click="tableLength('10')"> 加十行 </span>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. </template>
  104. <script>
  105. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  106. //例如:import 《组件名称》from ‘《组件路径》';
  107. import Header from "../../components/Header.vue";
  108. import NavMenu from "../../components/NavMenu.vue";
  109. import Breadcrumb from "../../components/Breadcrumb.vue";
  110. import { getLogin } from "@/api/ajax";
  111. import { cutMoneyFiter } from "@/utils/defined";
  112. import { mapState } from "vuex";
  113. export default {
  114. //import引入的组件需要注入到对象中才能使用
  115. components: { Header, NavMenu, Breadcrumb },
  116. props: {},
  117. filters: {
  118. cutMoneyFiter,
  119. },
  120. data() {
  121. //这里存放数据
  122. return {
  123. activeMenuIndex: "order_setting",
  124. breadcrumbList: [
  125. {
  126. icon: "setting",
  127. url: "",
  128. text: "",
  129. },
  130. {
  131. icon: "",
  132. url: "",
  133. notLink: true,
  134. text: "系统配置",
  135. },
  136. {
  137. icon: "",
  138. url: "",
  139. text: "订阅价格管理",
  140. },
  141. ],
  142. loading: false,
  143. typeValue: 1,
  144. tableList: [
  145. {
  146. issue_no: "",
  147. comb_count: "",
  148. shelve_date: "",
  149. price: "",
  150. },
  151. ],
  152. tableHeight: "", // 表格高度
  153. tableObj: {},
  154. tableLoading: false,
  155. };
  156. },
  157. //计算属性 类似于data概念
  158. computed: {
  159. ...mapState(["$studyType", "file_preview_url"]),
  160. },
  161. //监控data中数据变化
  162. watch: {},
  163. //方法集合
  164. methods: {
  165. handleChangeTabs(value) {
  166. this.typeValue = value;
  167. this.getInfo();
  168. },
  169. // 去掉前后空格
  170. handleTrim(form, fild) {
  171. this[form][fild] = this[form][fild].trim();
  172. },
  173. // 提交表单
  174. onSubmit() {
  175. let _this = this;
  176. this.loading = true;
  177. let MethodName =
  178. "/OrgServer/Manager/ReservationPriceManager/SaveReservationPriceList";
  179. // let index = 0;
  180. let key = this.typeValue;
  181. // Object.getOwnPropertyNames(_this.tableObj).forEach(function (key) {
  182. // if(_this.tableObj&&_this.tableObj[key]&&_this.tableObj[key].length>0){
  183. let table =
  184. _this.tableObj[key].length > 0
  185. ? JSON.parse(JSON.stringify(_this.tableObj[key]))
  186. : [];
  187. table.forEach((item) => {
  188. item.comb_count = item.comb_count ? item.comb_count * 1 : 1;
  189. item.price = item.price * 1;
  190. });
  191. let data = {
  192. goods_type: key == 1 ? 4 : 2,
  193. goods_study_phase: key * 1,
  194. reservation_price_list: table,
  195. };
  196. getLogin(MethodName, data)
  197. .then((res) => {
  198. // this.loading = false
  199. if (res.status === 1) {
  200. // index++;
  201. // if (index === Object.keys(_this.tableObj).length + 1) {
  202. _this.$message.success("保存成功");
  203. _this.loading = false;
  204. // }
  205. // this.$message.success("保存成功")
  206. }
  207. })
  208. .catch((res) => {
  209. _this.loading = false;
  210. });
  211. // }
  212. // });
  213. },
  214. // 取消 恢复到修改前状态
  215. onCancel() {},
  216. // 得到配置信息
  217. getInfo() {
  218. if (
  219. this.tableObj[this.typeValue] &&
  220. this.tableObj[this.typeValue].length > 0
  221. ) {
  222. return;
  223. }
  224. this.tableLoading = true;
  225. let MethodName =
  226. "/OrgServer/Manager/ReservationPriceManager/GetReservationPriceList";
  227. getLogin(MethodName, {
  228. goods_type: this.typeValue === 1 ? 4 : 2,
  229. goods_study_phase: this.typeValue,
  230. })
  231. .then((res) => {
  232. this.tableLoading = false;
  233. if (res.status === 1) {
  234. this.tableList = res.reservation_price_list;
  235. this.tableObj[this.typeValue] = res.reservation_price_list;
  236. this.$forceUpdate();
  237. }
  238. })
  239. .catch((res) => {
  240. this.tableLoading = false;
  241. });
  242. },
  243. //计算table高度(动态设置table高度)
  244. getTableHeight() {
  245. let tableH = 370; //距离页面下方的高度
  246. let tableHeightDetil = window.innerHeight - tableH;
  247. if (tableHeightDetil <= 300) {
  248. this.tableHeight = 300;
  249. } else {
  250. this.tableHeight = window.innerHeight - tableH;
  251. }
  252. },
  253. handlePrice(item) {
  254. item.price = cutMoneyFiter(item.price);
  255. },
  256. tableLength(type) {
  257. if (type == "-") {
  258. if (this.tableObj[this.typeValue].length > 1) {
  259. this.tableObj[this.typeValue].splice(
  260. this.tableObj[this.typeValue].length - 1,
  261. 1
  262. );
  263. } else {
  264. this.$message.warning("最少须保留一行");
  265. }
  266. } else {
  267. for (let i = 0; i < Number(type); i++) {
  268. let obj = {
  269. issue_no: "",
  270. comb_count: "",
  271. shelve_date: "",
  272. price: "",
  273. };
  274. this.tableObj[this.typeValue].push(obj);
  275. }
  276. }
  277. },
  278. },
  279. //生命周期 - 创建完成(可以访问当前this实例)
  280. created() {
  281. let timer = setInterval(() => {
  282. if (this.$studyType && this.$studyType.length > 0) {
  283. this.$studyType.forEach((item) => {
  284. this.tableObj[item.study_phase] = [];
  285. });
  286. this.getInfo();
  287. clearInterval(timer);
  288. }
  289. }, 1000);
  290. this.getTableHeight();
  291. },
  292. //生命周期 - 挂载完成(可以访问DOM元素)
  293. mounted() {},
  294. //生命周期-创建之前
  295. beforeCreated() {},
  296. //生命周期-挂载之前
  297. beforeMount() {},
  298. //生命周期-更新之前
  299. beforUpdate() {},
  300. //生命周期-更新之后
  301. updated() {},
  302. //生命周期-销毁之前
  303. beforeDestory() {},
  304. //生命周期-销毁完成
  305. destoryed() {},
  306. //如果页面有keep-alive缓存功能,这个函数会触发
  307. activated() {},
  308. };
  309. </script>
  310. <style lang="scss" scoped>
  311. /* @import url(); 引入css类 */
  312. .create-bottom {
  313. padding: 40px 40px;
  314. background: #ffffff;
  315. border-radius: 4px;
  316. height: calc(100vh - 140px);
  317. overflow: auto;
  318. .top-box {
  319. display: flex;
  320. justify-content: space-between;
  321. }
  322. h3 {
  323. font-size: 20px;
  324. font-weight: 500;
  325. line-height: 28px;
  326. margin: 0;
  327. color: #1d2129;
  328. }
  329. .tabs {
  330. display: flex;
  331. padding: 16px 0;
  332. a {
  333. font-size: 14px;
  334. line-height: 22px;
  335. color: #4e5969;
  336. border-radius: 100px;
  337. padding: 5px 16px;
  338. margin-right: 12px;
  339. &:hover {
  340. background: #f2f3f5;
  341. }
  342. &.active {
  343. background: #f2f3f5;
  344. font-weight: 500;
  345. color: #165dff;
  346. }
  347. }
  348. }
  349. }
  350. .order-table {
  351. margin-top: 0;
  352. .el-input {
  353. width: 135px;
  354. height: 22px;
  355. background: #ffffff;
  356. }
  357. }
  358. .quick-btn {
  359. border-radius: 4px;
  360. border: 1px solid rgba(0, 0, 0, 0.08);
  361. background: #f4f4f4;
  362. width: 219px;
  363. height: 30px;
  364. text-align: center;
  365. margin: 16px 8px 0 0;
  366. display: inline-block;
  367. color: #000;
  368. font-size: 14px;
  369. font-weight: 400;
  370. line-height: 26px; /* 157.143% */
  371. cursor: pointer;
  372. }
  373. </style>
  374. <style lang="scss">
  375. .order-table.el-table--enable-row-hover
  376. .el-table__body
  377. tr:hover
  378. > td.el-table__cell {
  379. background-color: transparent !important;
  380. }
  381. .order-table {
  382. .cell {
  383. padding: 0;
  384. }
  385. .el-table__row:hover {
  386. background-color: transparent !important;
  387. }
  388. .el-table__cell {
  389. padding: 9px 10px;
  390. }
  391. .el-input__inner {
  392. width: 132px;
  393. height: 22px;
  394. line-height: 22px;
  395. padding: 0;
  396. background: #ffffff;
  397. }
  398. }
  399. </style>