consumables.vue 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <div class="page_consumables">
  3. <div class="cell clearfix">
  4. <label class="title"> <span class="name">排班班次</span> : </label>
  5. <div class="time">
  6. <ul class>
  7. <li
  8. :class="item.value == schedulType ? 'active' : ''"
  9. @click="selectSchedulType(item.value)"
  10. v-for="item in schedulArr"
  11. :key="item.value"
  12. >
  13. {{ item.label }}
  14. </li>
  15. </ul>
  16. </div>
  17. <label class="title"><span class="name">日期查询</span> : </label>
  18. <el-date-picker size="small" v-model="selected_date" prefix-icon="el-icon-date" @change="handleScheduleDateChange"
  19. :editable="false" :clearable="false" style="width: 196px;margin-right:10px;" type="date"
  20. format="yyyy-MM-dd"
  21. value-format="yyyy-MM-dd"
  22. placeholder="选择日期时间" align="right"></el-date-picker>
  23. <el-input size="small" style="width: 180px;" @keyup.enter.native='searchAction' v-model.trim="search_input"
  24. class="filter-item" v-model="query.keywords"/>
  25. <el-button size="small" class="filter-item" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
  26. </div>
  27. <div class="cell clearfix" style="justify-content: space-between;">
  28. <div style="display:flex;">
  29. <label class="title"> <span class="name">分区</span> : </label>
  30. <div class="time">
  31. <ul class>
  32. <li
  33. :class="item.id == partitionType ? 'active' : ''"
  34. @click="selectPartitionType(item.id)"
  35. v-for="item in partitionArr"
  36. :key="item.id"
  37. >
  38. {{ item.name }}
  39. </li>
  40. </ul>
  41. </div>
  42. </div>
  43. <div>
  44. <!-- <el-button size="small" icon="el-icon-printer" @click="exportList" type="primary">导出</el-button> -->
  45. <el-button size="small" type="primary" @click="statistics">统计表</el-button>
  46. </div>
  47. </div>
  48. <div>
  49. <el-table
  50. :data="list"
  51. border
  52. :row-style="{ color: '#303133' }"
  53. :header-cell-style="{
  54. backgroundColor: 'rgb(245, 247, 250)',
  55. color: '#606266'
  56. }"
  57. >
  58. <el-table-column
  59. align="center"
  60. type="selection"
  61. width="55">
  62. </el-table-column>
  63. <el-table-column
  64. align="center"
  65. prop="name"
  66. v-for="item,index in good_types"
  67. :key="index"
  68. :label="item"
  69. >
  70. <template slot-scope="scope">
  71. <span>{{scope.row.good_type[index].name}}</span>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. </div>
  76. <el-pagination
  77. @size-change="handleSizeChange"
  78. @current-change="handleCurrentChange"
  79. :page-sizes="[10, 50, 100]"
  80. :page-size="10"
  81. background
  82. align="right"
  83. style="margin-top:20px;"
  84. layout="total, sizes, prev, pager, next, jumper"
  85. :total="total"
  86. >
  87. </el-pagination>
  88. <consumables-dialog ref="consumables" :list="new_list"></consumables-dialog>
  89. </div>
  90. </template>
  91. <script>
  92. import { GetAllZone,GetDialysisgoods } from '@/api/dialysis'
  93. import consumablesDialog from './consumablesDialog'
  94. import { uParseTime } from "@/utils/tools";
  95. export default {
  96. components: {
  97. consumablesDialog
  98. },
  99. data() {
  100. return {
  101. query:{
  102. total:"",
  103. schedule_date:"",
  104. schedule_type:0,
  105. partition_id:0,
  106. page:1,
  107. limit:10,
  108. keywords:"",
  109. },
  110. schedulType: 0,
  111. schedulArr: [
  112. { value: 0, label: '全部' },
  113. { value: 1, label: '上午' },
  114. { value: 2, label: '下午' },
  115. { value: 3, label: '晚上' }
  116. ],
  117. selected_date: "",
  118. partitionArr: [],
  119. partitionType: 0,
  120. tableData: [{
  121. date: '2016-05-03',
  122. name: '王小虎',
  123. address: '上海市普陀区金沙江路 1518 弄'
  124. }
  125. ],
  126. search_input: '',
  127. searchAction: '',
  128. allGoodInfo:[],
  129. list:[],
  130. new_list:[],
  131. good_types: [],
  132. arrKey:[],
  133. }
  134. },
  135. created() {
  136. this.getAllZone()
  137. let date = uParseTime(new Date(), "{y}-{m}-{d}")
  138. var newDate = new Date();
  139. var y = newDate.getFullYear();
  140. var m = newDate.getMonth() + 1;
  141. var d = newDate.getDate();
  142. var schedule_date =
  143. y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d);
  144. this.selected_date = date
  145. this.query.schedule_date = schedule_date
  146. this.query.schedule_type = 0
  147. this.query.partition_id = 0
  148. this.query.page = 1
  149. this.GetDialysisgoods()
  150. },
  151. methods: { handleSizeChange(val) {
  152. this.query.limit = val;
  153. this.GetDialysisgoods();
  154. },
  155. handleCurrentChange(val) {
  156. this.query.page = val;
  157. this.GetDialysisgoods();
  158. },
  159. calCount(query_warehouseout_info) {
  160. let total = 0
  161. var array = []
  162. array = query_warehouseout_info
  163. for (let i = 0; i < array.length; i++) {
  164. total = total + array[i].count
  165. }
  166. return total
  167. },
  168. getGoodUserInfo(good_type_id,good_user,last_good_user) {
  169. var arrlist =[]
  170. if (good_user != null && good_user.length > 0) {
  171. let desc = ""
  172. for (let b = 0; b < good_user.length; b++){
  173. if(good_type_id == good_user[b].good_type_id)
  174. desc = desc + "\n" + good_user[b].info.specification_name +"*" +good_user[b].count
  175. }
  176. arrlist.push(desc)
  177. return desc
  178. }
  179. console.log("arrlist---------",arrlist)
  180. return ""
  181. // else if (good_user != null && good_user.length <= 0) {
  182. // if (last_good_user != null && last_good_user.length > 0) {
  183. // let desc = ""
  184. // for (let b = 0; b < last_good_user.length; b++){
  185. // if(good_type_id == last_good_user[b].good_type_id)
  186. // desc = desc+ "\n" + last_good_user[b].info.specification_name +"*" +last_good_user[b].count
  187. // }
  188. // console.log(desc)
  189. //
  190. // return desc
  191. //
  192. // }
  193. // return ""
  194. // }
  195. },
  196. GetDialysisgoods() {
  197. GetDialysisgoods(this.query).then(response => {
  198. if (response.data.state == 0) {
  199. this.$message.error(response.data.msg)
  200. return false
  201. } else {
  202. this.list = []
  203. this.good_types = []
  204. this.allGoodInfo = []
  205. var res = response.data
  206. this.total = res.data.total
  207. this.good_types.push("姓名")
  208. var arr = []
  209. arr.push("name")
  210. for (let a = 0; a < res.data.good_type.length; a++){
  211. Object.keys(res.data.good_type[a]).map(item => {
  212. if(item == 'type_name'){
  213. arr.push(item)
  214. }
  215. })
  216. this.good_types.push(res.data.good_type[a].type_name)
  217. }
  218. this.arrKey.push(...arr)
  219. this.allGoodInfo = res.data.dialysis_goods
  220. for(let i = 0; i < res.data.dialysis_goods.length; i++){
  221. let arr =[]
  222. let obj = {
  223. id:0,
  224. name: res.data.dialysis_goods[i].patient.name,
  225. }
  226. arr.push(obj)
  227. for (let a = 0; a < res.data.good_type.length; a++){
  228. let obj = {
  229. id:res.data.good_type[a].id,
  230. name:""
  231. }
  232. arr.push(obj)
  233. }
  234. let newObj = {
  235. "good_type":arr,
  236. "good_user":res.data.dialysis_goods[i].good_user,
  237. "last_good_user":res.data.dialysis_goods[i].last_good_user,
  238. "good_user_detail":res.data.dialysis_goods[i].good_user_detail,
  239. "last_good_user_detail":res.data.dialysis_goods[i].last_good_user_detail,
  240. }
  241. this.list.push(newObj)
  242. }
  243. for (let a = 0; a < this.list.length; a++){
  244. for (let b = 0; b < this.list[a].good_type.length; b++){
  245. if(this.list[a].good_type[b].id > 0){
  246. this.list[a].good_type[b].name = this.getGoodUserInfo(this.list[a].good_type[b].id,this.list[a].good_user,this.list[a].last_good_user)
  247. }
  248. }
  249. }
  250. }
  251. console.log("list222222",this.list)
  252. })
  253. },
  254. selectSchedulType(scheduleType) {
  255. this.schedulType = scheduleType
  256. this.query.schedule_type = scheduleType
  257. this.query.page = 1
  258. this.GetDialysisgoods()
  259. },
  260. selectPartitionType(partitionType) {
  261. this.partitionType = partitionType
  262. this.query.partition_id = partitionType
  263. this.query.page = 1
  264. this.GetDialysisgoods()
  265. },
  266. getAllZone: function() {
  267. GetAllZone().then(response => {
  268. if (response.data.state == 0) {
  269. this.$message.error(response.data.msg)
  270. return false
  271. } else {
  272. this.partitionArr = response.data.data.zone
  273. this.partitionArr.unshift({ id: 0, name: '全部' })
  274. }
  275. })
  276. },
  277. statistics() {
  278. this.$refs.consumables.show()
  279. },
  280. handleScheduleDateChange(val) {
  281. this.query.schedule_date = val
  282. this.query.page = 1
  283. this.GetDialysisgoods()
  284. },
  285. search() {
  286. this.query.page = 1
  287. this.GetDialysisgoods()
  288. },
  289. exportList(){
  290. import('@/vendor/Export2Excel').then(excel => {
  291. const tHeader = this.good_types
  292. const filterVal = this.arrKey
  293. const data = this.formatJson(filterVal, this.list)
  294. excel.export_json_to_excel({
  295. header: tHeader,
  296. data,
  297. filename: '透析耗材查询'
  298. })
  299. this.downloadLoading = false
  300. })
  301. },
  302. formatJson(filterVal, jsonData) {
  303. return jsonData.map(v => filterVal.map(j => v[j]));
  304. },
  305. }
  306. }
  307. </script>
  308. <style lang="scss" scoped>
  309. .page_consumables {
  310. .clearfix:after {
  311. content: none;
  312. }
  313. }
  314. </style>