index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <!--部门数据-->
  5. <el-col :span="2" :xs="24" style="margin-top: 80px">
  6. <div class="head-container">
  7. <el-tabs v-model="checkWashMode" @tab-click="handleQuery" tab-position="left">
  8. <el-tab-pane v-for="item in clothWashModes" :label="item.name" :name="item.id + ''"></el-tab-pane>
  9. </el-tabs>
  10. </div>
  11. </el-col>
  12. <el-col :span="22" :xs="24">
  13. <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
  14. <el-form-item prop="checkStoreAreaId">
  15. <el-tabs v-model="checkStoreAreaId" @tab-click="handleQuery">
  16. <el-tab-pane v-for="item in areaList" :label="item.name" :name="item.id + ''"></el-tab-pane>
  17. </el-tabs>
  18. <!-- <el-select v-model="queryParams.storeAreaId" placeholder="请选择区域" clearable @change="handleQuery" filterable>-->
  19. <!-- <el-option v-for="(item, index) in areaList" :key="index" :label="item.name" :value="item.id" />-->
  20. <!-- </el-select>-->
  21. </el-form-item>
  22. <div></div>
  23. <el-form-item prop="name">
  24. <el-input v-model="queryParams.name" placeholder="请输入衣服名称" clearable @keyup.enter.native="handleQuery" />
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  28. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  29. </el-form-item>
  30. </el-form>
  31. <el-row :gutter="10" class="mb8">
  32. <el-col :span="1.5">
  33. <el-button type="primary" plain icon="el-icon-upload2" @click="handleImport">导入</el-button>
  34. </el-col>
  35. <el-col :span="1.5">
  36. <el-button type="warning" plain icon="el-icon-download" @click="handleExport">导出</el-button>
  37. </el-col>
  38. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  39. </el-row>
  40. <Page uri="/mapi/cloth/price/getClothPriceListByWashMode" :request-params="queryParams" ref="pagination">
  41. <el-table-column label="衣服ID" align="center" prop="clothId" />
  42. <el-table-column label="区域" align="center" prop="areaName" />
  43. <el-table-column label="衣服名称" align="center" prop="name" />
  44. <el-table-column label="洗衣方式名称" align="center" prop="washModeName" />
  45. <el-table-column label="价格" align="center" prop="price">
  46. <template slot-scope="scope">
  47. {{ scope.row.price ? scope.row.price : '未设置价格' }}
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="120">
  51. <template slot-scope="scope">
  52. <el-button type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">设置</el-button>
  53. </template>
  54. </el-table-column>
  55. </Page>
  56. </el-col>
  57. </el-row>
  58. <!-- 设置价格 -->
  59. <el-dialog title="设置价格" :visible.sync="unitPriceType" width="30%" :before-close="handleClose">
  60. <form ref="unitpriceForm">
  61. <el-input-number v-model="unitpriceForm.price" :min="1" :max="99999" :step="1" style="width: 100%" />
  62. </form>
  63. <span slot="footer" class="dialog-footer">
  64. <el-button @click="unitPriceType = false">取 消</el-button>
  65. <el-button type="primary" @click="setunitPrice('unitpriceForm')">提 交</el-button>
  66. </span>
  67. </el-dialog>
  68. <!-- 复制区域 -->
  69. <el-dialog title="区域复制" :visible.sync="open" size="30%" append-to-body>
  70. <el-row :gutter="15">
  71. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  72. <el-col :span="24">
  73. <el-form-item label="选择区域" prop="storeAreaIdFrom">
  74. <el-select v-model="form.storeAreaIdFrom" placeholder="请选择区域" clearable filterable>
  75. <el-option v-for="(item, index) in areaList" :key="index" :label="item.name" :value="item.id"
  76. :disabled="item.id == form.storeAreaIdTo" />
  77. </el-select>
  78. </el-form-item>
  79. <el-form-item label="复制区域" prop="storeAreaIdTo">
  80. <el-select v-model="form.storeAreaIdTo" placeholder="请选择复制区域" clearable filterable>
  81. <el-option v-for="(item, index) in areaList" :key="index" :label="item.name" :value="item.id"
  82. :disabled="item.id == form.storeAreaIdFrom" />
  83. </el-select>
  84. </el-form-item>
  85. <el-form-item label="价格倍数" prop="multiple">
  86. <el-input-number v-model="form.multiple" :min="0.01" :max="100" :step="0.01" style="width: 100%" />
  87. <div class="remark">价格倍数是以选择区域为底数乘以当前选择的价格倍数,最终得到复制区域的价格体系</div>
  88. </el-form-item>
  89. </el-col>
  90. </el-form>
  91. </el-row>
  92. <div slot="footer" class="dialog-footer">
  93. <el-button type="primary" @click="submitForm" style="margin-left: 5%">提交</el-button>
  94. <el-button @click="cancel">取 消</el-button>
  95. </div>
  96. </el-dialog>
  97. <!-- 导入对话框 -->
  98. <el-dialog :title="upload.title" :visible.sync="upload.open" width="40%" append-to-body>
  99. <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?storeAreaId=' + upload.storeAreaId"
  100. :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
  101. <i class="el-icon-upload"></i>
  102. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  103. <div class="el-upload__tip text-center" slot="tip">
  104. <span>仅允许导入xls、xlsx格式文件。</span>
  105. <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
  106. </div>
  107. </el-upload>
  108. <div slot="footer" class="dialog-footer">
  109. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  110. <el-button @click="upload.open = false">取 消</el-button>
  111. </div>
  112. </el-dialog>
  113. </div>
  114. </template>
  115. <script>
  116. import { listStoreArea } from '@/api/system/storeArea'
  117. import { getClothPriceListByWashMode, getWashMode, setPriceByClothType, setPriceByClothTypeCopyArea, setPriceByWashMode } from '@/api/cloth/unitPrice'
  118. import { getToken } from '@/utils/auth'
  119. export default {
  120. name: 'laundryPrice',
  121. dicts: ['sys_normal_disable'],
  122. data() {
  123. return {
  124. // 遮罩层
  125. loading: true,
  126. // 选中数组
  127. ids: [],
  128. // 非单个禁用
  129. single: true,
  130. // 非多个禁用
  131. multiple: true,
  132. // 显示搜索条件
  133. showSearch: true,
  134. // 总条数
  135. total: 0,
  136. clothType: null,
  137. // 单价表格数据
  138. unitPriceList: [],
  139. checkStoreAreaId: '1',
  140. checkWashMode: '1',
  141. // 弹出层标题
  142. title: '',
  143. // 是否显示弹出层
  144. open: false,
  145. // 查询参数
  146. queryParams: {
  147. washModeId: null,
  148. storeAreaId: null,
  149. name: null
  150. },
  151. // 导入参数
  152. upload: {
  153. // 是否显示弹出层(单价导入)
  154. open: false,
  155. // 弹出层标题(单价导入)
  156. title: '',
  157. // 是否禁用上传
  158. isUploading: false,
  159. //区域id
  160. storeAreaId: '',
  161. // 设置上传的请求头部
  162. headers: { Authorization: 'Bearer ' + getToken() },
  163. // 上传的地址
  164. url: process.env.VUE_APP_BASE_API + '/mapi/cloth/price/importData'
  165. },
  166. // 表单参数
  167. form: {},
  168. // 表单校验
  169. rules: {
  170. storeAreaIdFrom: [{ required: true, message: '请选择区域', trigger: 'change' }],
  171. storeAreaIdTo: [{ required: true, message: '请选择复制区域', trigger: 'change' }],
  172. multiple: [{ required: true, message: '清填写价格倍数', trigger: 'blur' }]
  173. },
  174. areaList: [],
  175. clothWashModes: [],
  176. unitPriceType: false,
  177. unitpriceForm: {}
  178. }
  179. },
  180. created() {
  181. this.getAreaList()
  182. this.getwashList()
  183. this.getList()
  184. },
  185. methods: {
  186. /** 导入按钮操作 */
  187. handleImport() {
  188. if (!this.queryParams.storeAreaId) {
  189. this.$modal.msgError('请选择区域')
  190. return false
  191. }
  192. this.upload.storeAreaId = this.queryParams.storeAreaId
  193. const up_name = this.areaList.find((item) => item.id === this.queryParams.storeAreaId)?.name
  194. this.upload.title = `【${up_name}】 洗衣方式单价导入`
  195. this.upload.open = true
  196. },
  197. /** 下载模板操作 */
  198. importTemplate() {
  199. this.download('/mapi/cloth/price/downloadTemplate', {}, `衣服单价导入模板.xlsx`)
  200. },
  201. // 文件上传中处理
  202. handleFileUploadProgress(event, file, fileList) {
  203. this.upload.isUploading = true
  204. },
  205. // 文件上传成功处理
  206. handleFileSuccess(response, file, fileList) {
  207. this.upload.open = false
  208. this.upload.isUploading = false
  209. this.$refs.upload.clearFiles()
  210. var respMsg = response.code == '200' ? '' : '导入失败!'
  211. this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + respMsg + '<br/>' + response.msg + '</div>', '导入结果', { dangerouslyUseHTMLString: true })
  212. this.getList()
  213. },
  214. // 提交上传文件
  215. submitFileForm() {
  216. this.$refs.upload.submit()
  217. },
  218. /** 查询衣服品牌列表 */
  219. getList() {
  220. console.log('@@@@@@' + this.checkWashMode)
  221. this.queryParams.storeAreaId = parseInt(this.checkStoreAreaId)
  222. this.queryParams.washModeId = parseInt(this.checkWashMode)
  223. this.$nextTick(() => {
  224. this.$refs.pagination.handleSearch(true)
  225. })
  226. },
  227. getAreaList() {
  228. listStoreArea({ pageSize: 10000, pageNum: 1, status: '0' }).then((res) => {
  229. this.areaList = res.rows
  230. })
  231. },
  232. getwashList() {
  233. getWashMode().then((res) => {
  234. this.clothWashModes = res.data
  235. })
  236. },
  237. // 表单重置
  238. reset() {
  239. this.form = {
  240. storeAreaIdFrom: null,
  241. storeAreaIdTo: null,
  242. multiple: null
  243. }
  244. this.resetForm('form')
  245. },
  246. // 取消按钮
  247. cancel() {
  248. this.reset()
  249. this.open = false
  250. },
  251. /** 搜索按钮操作 */
  252. handleQuery() {
  253. this.getList()
  254. },
  255. /** 重置按钮操作 */
  256. resetQuery() {
  257. this.resetForm('queryForm')
  258. this.handleQuery()
  259. },
  260. /** 区域复制按钮操作 */
  261. handleCopy() {
  262. this.open = true
  263. },
  264. /** 设置按钮操作 */
  265. handleUpdate(row) {
  266. this.unitpriceForm = Object.assign({}, row)
  267. this.unitPriceType = true
  268. },
  269. /** 提交按钮 */
  270. submitForm() {
  271. this.$refs['form'].validate((valid) => {
  272. if (valid) {
  273. setPriceByWashMode({ ...this.form, ...{ washMode: this.checkWashMode } }).then((response) => {
  274. this.$modal.msgSuccess('复制成功')
  275. this.open = false
  276. this.getList()
  277. })
  278. }
  279. })
  280. },
  281. checkClose(done) {
  282. this.$confirm('是否关闭表单,关闭后数据将丢失?')
  283. .then(function () {
  284. done()
  285. })
  286. .then(() => { })
  287. .catch(() => { })
  288. },
  289. setunitPrice() {
  290. if (!this.unitpriceForm.price) {
  291. this.$modal.msgError('请输入价格')
  292. return
  293. }
  294. setPriceByWashMode({ ...this.unitpriceForm, ...{ washMode: this.checkWashMode } }).then((response) => {
  295. this.$modal.msgSuccess('设置成功')
  296. this.unitPriceType = false
  297. this.getList()
  298. })
  299. },
  300. handleClose(done) {
  301. this.$confirm('是否关闭设置表单?')
  302. .then((_) => {
  303. done()
  304. })
  305. .catch((_) => { })
  306. }
  307. }
  308. }
  309. </script>
  310. <style lang="scss" scoped>
  311. .remark {
  312. margin-top: 10px;
  313. background-color: rgba(255, 228, 74, 0.1);
  314. border: 1px dashed #ffe44a;
  315. font-size: 14px;
  316. color: #e6a23c;
  317. width: 100%;
  318. padding: 20px;
  319. border-radius: 5px;
  320. line-height: 25px;
  321. }
  322. </style>