tb-goods-list.html 17 KB

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