item-list-layer.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <el-dialog
  3. title="选择花材"
  4. :visible.sync="selDialog"
  5. :close-on-click-modal="false"
  6. :append-to-body="true"
  7. @close="$emit('update:show', false)"
  8. width="950px"
  9. >
  10. <div class="recharge-modal-content">
  11. <el-checkbox-group v-model="checkList" class="radio-wrap">
  12. <x-crud class="liu-crud-wrap" @load="onLoad">
  13. <template #table-column-radio="{scope}" >
  14. <div>
  15. <el-checkbox
  16. v-if="scope.row.select == 2"
  17. disabled
  18. :label="scope.row"
  19. >{{scope.row.id}}</el-checkbox>
  20. <el-checkbox
  21. v-else
  22. :label="scope.row"
  23. @click.stop.native="stop"
  24. >{{scope.row.id}}</el-checkbox>
  25. </div>
  26. </template>
  27. <template #table-column-select="{scope}">
  28. <span v-if="scope.row.select == 2">✔</span>
  29. <span v-else></span>
  30. </template>
  31. <template #table-column-stockWarning="{scope}">
  32. <el-input
  33. v-model="scope.row.stockWarning"
  34. @click.stop.native="stop"
  35. placeholder="库存预警值"
  36. size="small"
  37. ></el-input>
  38. </template>
  39. <template #table-column-cost="{scope}">
  40. <el-input
  41. v-model="scope.row.cost"
  42. placeholder="成本价"
  43. @click.stop.native="stop"
  44. size="small"
  45. ></el-input>
  46. </template>
  47. <template #table-column-addPrice="{scope}">
  48. <el-input
  49. v-model="scope.row.addPrice"
  50. placeholder="加价"
  51. @click.stop.native="stop"
  52. size="small"
  53. ></el-input>
  54. </template>
  55. <template #table-column-cover="{scope}">
  56. <div>
  57. <cl-avatar
  58. shape="square"
  59. :size="40"
  60. :src="scope.row.cover | default_avatar"
  61. :style="{ margin: 'auto' }"
  62. ></cl-avatar>
  63. </div>
  64. </template>
  65. </x-crud>
  66. </el-checkbox-group>
  67. <div>
  68. <span>花材分类:</span>
  69. <el-select
  70. style="width:300px;"
  71. v-model="sonClassName"
  72. size="small"
  73. placeholder="请选择分类"
  74. @change="selClassFn"
  75. >
  76. <el-option
  77. v-for="(item, index) in itemClassList"
  78. :key="index"
  79. :value="item.name"
  80. >{{ item.name }}</el-option>
  81. </el-select>
  82. </div>
  83. </div>
  84. <div
  85. slot="footer"
  86. class="dialog-footer"
  87. >
  88. <el-button
  89. size="small"
  90. @click="resetForm"
  91. >取 消</el-button>
  92. <el-button
  93. type="primary"
  94. size="small"
  95. @click="confirmFn"
  96. >确定</el-button>
  97. </div>
  98. </el-dialog>
  99. </template>
  100. <script>
  101. export default {
  102. name: 'sj-list-layer',
  103. props: {
  104. show: {
  105. type: Boolean,
  106. default: false
  107. },
  108. classId: {
  109. type: Number,
  110. default: 0
  111. },
  112. multi: {
  113. type: Boolean,
  114. default: false
  115. },
  116. className: {
  117. type: String,
  118. default: ''
  119. }
  120. },
  121. data () {
  122. return {
  123. selDialog: false,
  124. ruleForm: {},
  125. checkList: [],
  126. list: [],
  127. //分类列表
  128. itemClassList: [],
  129. sonClassId: 0,
  130. sonClassName: '',
  131. newApp: ''
  132. };
  133. },
  134. computed: {
  135. },
  136. watch: {
  137. show (val) {
  138. this.selDialog = this.show;
  139. }
  140. },
  141. created () {
  142. },
  143. methods: {
  144. stop () { },
  145. selClassFn (val) {
  146. let index = this.itemClassList.findIndex((e) => e.name == val)
  147. this.sonClassId = this.itemClassList[index].id
  148. },
  149. getAllClass () {
  150. this.$service.itemClass.getAllClass({pageSize: 1000}).then((res) => {
  151. this.itemClassList = res.list
  152. })
  153. },
  154. confirmFn () {
  155. if (this.checkList.length == 0) {
  156. this.$message.warning('请选择花材')
  157. return false
  158. }
  159. if (this.sonClassId == 0) {
  160. this.$message.warning('请选择分类')
  161. return false
  162. }
  163. this.$emit('confirm', { list: this.checkList, classId: this.sonClassId })
  164. },
  165. resetForm () {
  166. this.$emit('cancel');
  167. },
  168. selectItem (row) {
  169. console.log(1212121121)
  170. console.log(row)
  171. //已经选过
  172. if (row.select == 2) {
  173. return false
  174. }
  175. let index = this.checkList.findIndex(e => e.id == row.id)
  176. if (index === -1) {
  177. this.checkList = [row, ...this.checkList]
  178. } else {
  179. this.checkList.splice(index, 1)
  180. }
  181. },
  182. onLoad ({ ctx, app }) {
  183. this.sonClassId = this.classId
  184. this.sonClassName = this.className
  185. this.app = app
  186. //分类列表
  187. this.getAllClass()
  188. ctx.service(this.$service.ptItem)
  189. .set('table', {
  190. columns: [
  191. {
  192. prop: 'radio',
  193. label: '选择',
  194. align: 'center',
  195. width: 110
  196. },
  197. {
  198. prop: 'cover',
  199. label: '图片',
  200. align: 'center',
  201. width: 120
  202. },
  203. {
  204. prop: 'name',
  205. label: '名称',
  206. align: 'center'
  207. },
  208. {
  209. prop: 'stockWarning',
  210. label: '库存预警值',
  211. align: 'center'
  212. },
  213. {
  214. prop: 'cost',
  215. label: '成本价',
  216. align: 'center'
  217. },
  218. {
  219. prop: 'addPrice',
  220. label: '加价',
  221. align: 'center'
  222. },
  223. {
  224. prop: 'weight',
  225. label: '重量',
  226. align: 'center'
  227. },
  228. {
  229. prop: 'select',
  230. label: '已添加',
  231. align: 'center'
  232. }
  233. ],
  234. on: {
  235. 'row-click': (row, column) => {
  236. this.selectItem(row)
  237. }
  238. },
  239. // 操作列
  240. op: {
  241. visible: false // 是否显示
  242. }
  243. })
  244. .set('dict', {
  245. search: {
  246. keyWord: 'search'
  247. }
  248. })
  249. .set('search', {
  250. key: {
  251. placeholder: '花材名称,支持拼音首字母搜索'
  252. }
  253. })
  254. .set('pagination', {
  255. size: 6
  256. })
  257. .set('layout', [
  258. ['slot-tabs'],
  259. ['search-key', 'flex1', 'refresh-btn'],
  260. ['data-table'],
  261. ['flex1', 'pagination']
  262. ])
  263. .on('refresh', async (params, { next, render }) => {
  264. // 继续执行刷新
  265. let { list } = await next(params);
  266. list.map((e, index) => {
  267. e.index = index;
  268. });
  269. this.list = list;
  270. render(list);
  271. })
  272. .done();
  273. app.refresh();
  274. }
  275. }
  276. };
  277. </script>
  278. <style lang="scss">
  279. // 列表
  280. .radio-wrap {
  281. display: block;
  282. }
  283. .el-dialog{
  284. //margin-top: 10px !important;
  285. margin: 10px auto 10px !important;
  286. }
  287. </style>