tb-goods-list.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>商品管理-列表</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport"
  7. content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
  8. <!-- 所有的 css & js 资源 -->
  9. <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
  10. <link rel="stylesheet" href="../../static/sa.css">
  11. <script src="../../static/kj/vue.min.js"></script>
  12. <script src="../../static/kj/element-ui/index.js"></script>
  13. <script src="../../static/kj/httpVueLoader.js"></script>
  14. <script src="../../static/kj/jquery.min.js"></script>
  15. <script src="../../static/kj/layer/layer.js"></script>
  16. <script src="../../static/sa.js"></script>
  17. </head>
  18. <body>
  19. <div class="vue-box" style="display: none;" :style="'display: block;'">
  20. <div class="c-panel">
  21. <!-- ------------- 检索参数 ------------- -->
  22. <div class="c-title">检索参数</div>
  23. <el-form ref="form" :model='p' @submit.native.prevent>
  24. <sa-item type="text" name="名称" v-model="p.name"></sa-item>
  25. <el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询</el-button>
  26. <el-button type="info" icon="el-icon-search" @click="p.name = ''; f5()">重置</el-button>
  27. <el-button v-if="sa.isAuth('tb-goods-add')" size="mini" type="primary" @click="add()">增加</el-button>
  28. <br/>
  29. </el-form>
  30. <!-- ------------- 数据列表 ------------- -->
  31. <el-table class="data-table" ref="data-table" :data="dataList">
  32. <el-table-column type="index" width="50">
  33. </el-table-column>
  34. <sa-td name="业务名称" prop="name" width="120"></sa-td>
  35. <sa-td name="付款步骤" prop="payStep" type="enum" :jv="{1: '下单后', 2: '确认后'}" width="80"></sa-td>
  36. <sa-td name="载重" prop="needWeight" type="switch" :jv="{0: '选填[#005500]', 1: '必填[#ff0000]'}"
  37. @change="s => updateNeedWeight(s.row)" width="90"></sa-td>
  38. <sa-td name="规格" prop="needCarSize" type="switch" :jv="{0: '选填[#005500]', 1: '必填[#ff0000]'}"
  39. @change="s => updateNeedCarSize(s.row)" width="90"></sa-td>
  40. <sa-td name="车辆" prop="mulCar" type="switch" :jv="{0: '单辆[#005500]', 1: '多辆[#ff0000]'}"
  41. @change="s => updateMulCar(s.row)" width="90"></sa-td>
  42. <sa-td name="客户" prop="needCustomer" type="switch" :jv="{0: '选填[#005500]', 1: '必填[#ff0000]'}"
  43. @change="s => updateNeedCustomer(s.row)" width="90"></sa-td>
  44. <sa-td name="货物" prop="needOwner" type="switch" :jv="{0: '选填[#005500]', 1: '必填[#ff0000]'}"
  45. @change="s => updateNeedOwner(s.row)" width="90"></sa-td>
  46. <sa-td name="件数" prop="needOperateTime" type="switch" :jv="{0: '选填[#005500]', 1: '必填[#ff0000]'}"
  47. @change="s => updateNeedOperateTime(s.row)" width="90"></sa-td>
  48. <sa-td name="空车" prop="chinaCarPay" type="switch" :jv="{0: '免停车费[#005500]', 1: '收停车费[#ff0000]'}"
  49. @change="s => updateChinaCarPay(s.row)" width="120"></sa-td>
  50. <sa-td name="载重车" prop="vietnamCarPay" type="switch" :jv="{0: '免停车费[#005500]', 1: '收停车费[#ff0000]'}"
  51. @change="s => updateVietnamCarPay(s.row)" width="120"></sa-td>
  52. <el-table-column label="空车离场限制" width="140">
  53. <template slot-scope="s">
  54. <el-select v-model="s.row.chinaCarLeave" @change="chinaLeaveChange(s.row)">
  55. <el-option v-for="item in leaveSetting" :key="item.id" :value="item.id"
  56. :label="item.name">
  57. </el-option>
  58. </el-select>
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="载重车离场限制" width="140">
  62. <template slot-scope="s">
  63. <el-select v-model="s.row.vietnamCarLeave" @change="vietnamLeaveChange(s.row)">
  64. <el-option v-for="item in leaveSetting" :key="item.id" :value="item.id"
  65. :label="item.name">
  66. </el-option>
  67. </el-select>
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="预充值自动扣费类型" width="140">
  71. <template slot-scope="s">
  72. <el-select v-model="s.row.autoDeductionType" @change="deductionTypeChange(s.row)">
  73. <el-option v-for="item in deductionTypeList" :key="item.id" :value="item.id"
  74. :label="item.name">
  75. </el-option>
  76. </el-select>
  77. </template>
  78. </el-table-column>
  79. <sa-td name="创建时间" prop="createTime" width="160"></sa-td>
  80. <el-table-column label="操作" fixed="right" width="230">
  81. <template slot-scope="s">
  82. <el-button v-if="sa.isAuth('tb-goods-item-type')" class="c-btn" type="primary"
  83. @click="businessFn(s.row)">收费项
  84. </el-button>
  85. <el-button v-if="sa.isAuth('tb-goods-edit')" class="c-btn" type="primary"
  86. icon="el-icon-edit" @click="update(s.row)">修改
  87. </el-button>
  88. <el-button v-if="sa.isAuth('tb-goods-del')" class="c-btn" type="danger"
  89. icon="el-icon-delete" @click="del(s.row)">删除
  90. </el-button>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. <!-- ------------- 分页 ------------- -->
  95. <sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()">
  96. </sa-item>
  97. </div>
  98. </div>
  99. <script>
  100. var app = new Vue({
  101. components: {
  102. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  103. "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),
  104. },
  105. el: '.vue-box',
  106. data: {
  107. p: { // 查询参数
  108. name: '', // 名称
  109. pageNo: 1, // 当前页
  110. pageSize: 10, // 页大小
  111. sortType: 0 // 排序方式
  112. },
  113. dataCount: 0,
  114. dataList: [], // 数据集合
  115. leaveSetting: [],
  116. deductionTypeList: []
  117. },
  118. methods: {
  119. businessFn(data) {
  120. sa.showIframe('收费项', '../relation-goods-type/relation-goods-type-list.html?goodsId=' + data.id,
  121. '1080px', '90%');
  122. },
  123. // 刷新
  124. f5: function () {
  125. sa.ajax('/TbGoods/getList', sa.removeNull(this.p), function (res) {
  126. this.dataList = res.data; // 数据
  127. this.dataCount = res.dataCount; // 数据总数
  128. sa.f5TableHeight(); // 刷新表格高度
  129. }.bind(this));
  130. },
  131. getLeaveSetting: function () {
  132. sa.ajax('/TbGoods/getLeaveSetting', function (res) {
  133. this.leaveSetting = res.data; // 数据
  134. }.bind(this));
  135. },
  136. getDeductionTypeList: function () {
  137. sa.ajax('/TbGoods/getDeductionTypeList', function (res) {
  138. this.deductionTypeList = res.data; // 数据
  139. }.bind(this));
  140. },
  141. chinaLeaveChange(v) {
  142. let obj = {
  143. id: v.id,
  144. chinaCarLeave: v.chinaCarLeave
  145. }
  146. sa.ajax('/TbGoods/chinaLeaveChange', obj, function (resp) {
  147. }.bind(this))
  148. },
  149. vietnamLeaveChange(v) {
  150. let obj = {
  151. id: v.id,
  152. vietnamCarLeave: v.vietnamCarLeave
  153. }
  154. sa.ajax('/TbGoods/vietnamLeaveChange', obj, function (resp) {
  155. }.bind(this))
  156. },
  157. deductionTypeChange(v) {
  158. let obj = {
  159. id: v.id,
  160. autoDeductionType: v.autoDeductionType
  161. }
  162. sa.ajax('/TbGoods/autoDeductionType', obj, function (resp) {
  163. }.bind(this))
  164. },
  165. updateMulCar(data) {
  166. let obj = {
  167. id: data.id,
  168. mulCar: data.mulCar
  169. }
  170. sa.ajax('/TbGoods/updateMulCar', obj, function (resp) {
  171. }.bind(this))
  172. },
  173. updateNeedOwner(v) {
  174. let obj = {
  175. id: v.id,
  176. value: v.needOwner
  177. }
  178. sa.ajax('/TbGoods/updateNeedOwner', obj, function (resp) {
  179. }.bind(this))
  180. },
  181. updateNeedCustomer(v) {
  182. let obj = {
  183. id: v.id,
  184. value: v.needCustomer
  185. }
  186. sa.ajax('/TbGoods/updateNeedCustomer', obj, function (resp) {
  187. }.bind(this))
  188. },
  189. // 查看
  190. get: function (data) {
  191. sa.showIframe('数据详情', 'tb-goods-info.html?id=' + data.id, '1050px', '90%');
  192. },
  193. // 查看 - 根据选中的
  194. getBySelect: function (data) {
  195. var selection = this.$refs['data-table'].selection;
  196. if (selection.length == 0) {
  197. return sa.msg('请选择一条数据')
  198. }
  199. this.get(selection[0]);
  200. },
  201. // 修改
  202. update: function (data) {
  203. sa.showIframe('修改数据', 'tb-goods-add.html?id=' + data.id, '450px', '50%');
  204. },
  205. // 新增
  206. add: function (data) {
  207. sa.showIframe('新增数据', 'tb-goods-add.html?id=-1', '450px', '50%');
  208. },
  209. // 删除
  210. del: function (data) {
  211. sa.confirm('是否删除,此操作不可撤销', function () {
  212. sa.ajax('/TbGoods/delete?id=' + data.id, function (res) {
  213. sa.arrayDelete(this.dataList, data);
  214. sa.ok('删除成功');
  215. sa.f5TableHeight(); // 刷新表格高度
  216. }.bind(this))
  217. }.bind(this));
  218. },
  219. // 批量删除
  220. deleteByIds: function () {
  221. // 获取选中元素的id列表
  222. let selection = this.$refs['data-table'].selection;
  223. let ids = sa.getArrayField(selection, 'id');
  224. if (selection.length == 0) {
  225. return sa.msg('请至少选择一条数据')
  226. }
  227. // 提交删除
  228. sa.confirm('是否批量删除选中数据?此操作不可撤销', function () {
  229. sa.ajax('/TbGoods/deleteByIds', {
  230. ids: ids.join(',')
  231. }, function (res) {
  232. sa.arrayDelete(this.dataList, selection);
  233. sa.ok('删除成功');
  234. sa.f5TableHeight(); // 刷新表格高度
  235. }.bind(this))
  236. }.bind(this));
  237. },
  238. // 改 - 状态(1=禁用,2=启用)
  239. updateStatus: function (data) {
  240. // 声明变量记录是否成功
  241. var isOk = false;
  242. var oldValue = data.status;
  243. var ajax = sa.ajax('/TbGoods/updateStatus', {
  244. id: data.id,
  245. value: data.status
  246. }, function (res) {
  247. isOk = true;
  248. sa.msg('修改成功');
  249. }.bind(this));
  250. // 如果未能修改成功, 则回滚
  251. $.when(ajax).done(function () {
  252. if (isOk == false) {
  253. data.status = oldValue;
  254. }
  255. })
  256. },
  257. // 改 - 载重是否必填(1=是,0=否)
  258. updateNeedWeight: function (data) {
  259. // 声明变量记录是否成功
  260. var isOk = false;
  261. var oldValue = data.needWeight;
  262. var ajax = sa.ajax('/TbGoods/updateNeedWeight', {
  263. id: data.id,
  264. value: data.needWeight
  265. }, function (res) {
  266. isOk = true;
  267. sa.msg('修改成功');
  268. }.bind(this));
  269. // 如果未能修改成功, 则回滚
  270. $.when(ajax).done(function () {
  271. if (isOk == false) {
  272. data.status = oldValue;
  273. }
  274. })
  275. },
  276. // 改 - 规格是否必填(1=是,0=否)
  277. updateNeedCarSize: function (data) {
  278. // 声明变量记录是否成功
  279. var isOk = false;
  280. var oldValue = data.needCarSize;
  281. var ajax = sa.ajax('/TbGoods/updateNeedCarSize', {
  282. id: data.id,
  283. value: data.needCarSize
  284. }, function (res) {
  285. isOk = true;
  286. sa.msg('修改成功');
  287. }.bind(this));
  288. // 如果未能修改成功, 则回滚
  289. $.when(ajax).done(function () {
  290. if (isOk == false) {
  291. data.status = oldValue;
  292. }
  293. })
  294. },
  295. // 改 - 规格是否必填(1=是,0=否)
  296. updateChinaCarPay: function (data) {
  297. // 声明变量记录是否成功
  298. var isOk = false;
  299. var oldValue = data.chinaCarPay;
  300. var ajax = sa.ajax('/TbGoods/updateChinaCarPay', {
  301. id: data.id,
  302. value: data.chinaCarPay
  303. }, function (res) {
  304. isOk = true;
  305. sa.msg('修改成功');
  306. }.bind(this));
  307. // 如果未能修改成功, 则回滚
  308. $.when(ajax).done(function () {
  309. if (isOk == false) {
  310. data.status = oldValue;
  311. }
  312. })
  313. },
  314. // 改 - 规格是否必填(1=是,0=否)
  315. updateVietnamCarPay: function (data) {
  316. // 声明变量记录是否成功
  317. var isOk = false;
  318. var oldValue = data.vietnamCarPay;
  319. var ajax = sa.ajax('/TbGoods/updateVietnamCarPay', {
  320. id: data.id,
  321. value: data.vietnamCarPay
  322. }, function (res) {
  323. isOk = true;
  324. sa.msg('修改成功');
  325. }.bind(this));
  326. // 如果未能修改成功, 则回滚
  327. $.when(ajax).done(function () {
  328. if (isOk == false) {
  329. data.status = oldValue;
  330. }
  331. })
  332. },
  333. // 改 - 申报单是否必填(1=是,0=否)
  334. updateNeedDeclare: function (data) {
  335. // 声明变量记录是否成功
  336. var isOk = false;
  337. var oldValue = data.needDeclare;
  338. var ajax = sa.ajax('/TbGoods/updateNeedDeclare', {
  339. id: data.id,
  340. value: data.needDeclare
  341. }, function (res) {
  342. isOk = true;
  343. sa.msg('修改成功');
  344. }.bind(this));
  345. // 如果未能修改成功, 则回滚
  346. $.when(ajax).done(function () {
  347. if (isOk == false) {
  348. data.status = oldValue;
  349. }
  350. })
  351. },
  352. // 改 - 申报时间是否必填(1=是,0=否)
  353. updateNeedOperateTime: function (data) {
  354. // 声明变量记录是否成功
  355. var isOk = false;
  356. var oldValue = data.needOperateTime;
  357. var ajax = sa.ajax('/TbGoods/updateNeedOperateTime', {
  358. id: data.id,
  359. value: data.needOperateTime
  360. }, function (res) {
  361. isOk = true;
  362. sa.msg('修改成功');
  363. }.bind(this));
  364. // 如果未能修改成功, 则回滚
  365. $.when(ajax).done(function () {
  366. if (isOk == false) {
  367. data.status = oldValue;
  368. }
  369. })
  370. },
  371. },
  372. created: function () {
  373. this.f5();
  374. this.getLeaveSetting();
  375. this.getDeductionTypeList();
  376. sa.onInputEnter();
  377. }
  378. })
  379. </script>
  380. </body>
  381. </html>