index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="70px">
  4. <gong-zhu @btns='handleQuery' ref="cdhe" @input="resetQuery"/>
  5. </el-form>
  6. <el-row :gutter="10" class="mb8">
  7. <el-col :span="1.5">
  8. <el-button
  9. type="warning"
  10. plain
  11. icon="el-icon-download"
  12. size="mini"
  13. @click="handleExport"
  14. >导出</el-button>
  15. </el-col>
  16. <!-- <el-col :span="1.5">
  17. <el-button
  18. type="warning"
  19. plain
  20. icon="el-icon-download"
  21. size="mini"
  22. @click="handleExportgt"
  23. >打印</el-button>
  24. </el-col> -->
  25. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  26. </el-row>
  27. <div id="jue">
  28. <el-table height="250" v-loading="loading" :data="pigletcheckList" :span-method="objectSpanMethod" >
  29. <el-table-column >
  30. <el-table-column label="品种" align="center" prop="pz" :formatter="pzpxFormat" />
  31. <el-table-column label="类型" align="center" prop="lx" />
  32. <el-table-column label="养殖场名称" align="center" prop="name" width="120px"/>
  33. </el-table-column>
  34. <el-table-column >
  35. <el-table-column label="期初" align="center" prop="qc" />
  36. <el-table-column label="转入" align="center" prop="zr" />
  37. <el-table-column label="转出" align="center" prop="zc" />
  38. </el-table-column>
  39. <el-table-column label='购入' align="center">
  40. <el-table-column label="进口" align="center" prop="jk" />
  41. <el-table-column label="国内购买" align="center" prop="gngm"/>
  42. <el-table-column label="购入小计" align="center" prop="gmhj" />
  43. </el-table-column>
  44. <el-table-column label="销售" align="center">
  45. <el-table-column label="出口" align="center" prop="ck" />
  46. <el-table-column label="国内销售" align="center" prop="gnxs" />
  47. <el-table-column label="场间销售" align="center" prop="cjxs" />
  48. <el-table-column label="销售淘汰" align="center" prop="xstt" />
  49. </el-table-column>
  50. <el-table-column >
  51. <el-table-column label="屠宰" align="center" prop="tz"/>
  52. <el-table-column label="死亡" align="center" prop="sw" />
  53. </el-table-column>
  54. </el-table>
  55. </div>
  56. <!-- <pagination
  57. v-show="total>0"
  58. :total="total"
  59. :page.sync="queryParams.pageNum"
  60. :limit.sync="queryParams.pageSize"
  61. @pagination="getList"
  62. /> -->
  63. </div>
  64. </template>
  65. <script>
  66. import { listPigletcheck, listDept, getPigletcheck, delPigletcheck, addPigletcheck, updatePigletcheck, exportPigletcheck ,listPighomelist} from "@/api/statistics/boarReport/boarStock";
  67. export default {
  68. name: "Pigletcheck",
  69. components: {
  70. },
  71. data() {
  72. return {
  73. // 遮罩层
  74. loading: false,
  75. // 选中数组
  76. ids: [],
  77. // 非单个禁用
  78. single: true,
  79. // 非多个禁用
  80. multiple: true,
  81. // 显示搜索条件
  82. showSearch: true,
  83. // 总条数
  84. total: 0,
  85. // 仔猪育肥猪盘点表格数据
  86. pigletcheckList: [],
  87. //猪舍数据
  88. pighomeList: [],
  89. //品种品系数据
  90. pzpxOptions: [],
  91. //猪只类别
  92. zzlbOptions: [],
  93. //商品等级
  94. spdjOptions: [],
  95. // 弹出层标题
  96. title: "",
  97. // 是否显示弹出层
  98. open: false,
  99. // 查询参数
  100. queryParams: {
  101. condition:{
  102. }
  103. },
  104. // 表单参数
  105. form: {},
  106. // 表单校验
  107. rules: {
  108. createTime: [
  109. { required: true, message: "create_time不能为空", trigger: "blur" }
  110. ],
  111. updateTime: [
  112. { required: true, message: "update_time不能为空", trigger: "blur" }
  113. ],
  114. },
  115. deptOptions:[],
  116. optionPropstwo: {
  117. value: 'deptId',
  118. label: 'deptName',
  119. children: 'children',
  120. checkStrictly: true
  121. },
  122. spanArr:[],
  123. pos:0
  124. };
  125. },
  126. created() {
  127. this.queryParams.condition.endTime = this.getset()
  128. this.getList();
  129. this.getPighome();
  130. this.getDicts("pzpx").then(response => {
  131. this.pzpxOptions = response.data;
  132. });
  133. this.getDicts("group_two").then(response => {
  134. this.zzlbOptions = response.data;
  135. });
  136. this.getDicts("group_one").then(response => {
  137. this.spdjOptions = response.data;
  138. });
  139. // this.diertw()
  140. },
  141. methods: {
  142. /** 查询仔猪育肥猪盘点列表 */
  143. getList() {
  144. this.loading = true;
  145. listPigletcheck(this.queryParams).then(response => {
  146. this.pigletcheckList = response.rows;
  147. this.total = response.total;
  148. this.loading = false;
  149. let pigletcheckList = this.pigletcheckList;
  150. this.getSpanArr(pigletcheckList)
  151. });
  152. },
  153. /*查询猪舍信息*/
  154. getPighome(){
  155. // this.loading = true;
  156. listPighomelist(this.queryParams).then(response => {
  157. this.loading = false
  158. this.pighomeList = response.data;
  159. });
  160. },
  161. getSpanArr(data) { 
  162. this.spanArr = []
  163. this.pos = 0
  164. for (var i = 0; i < data.length; i++) {
  165. if (i === 0) {
  166. this.spanArr.push(1);
  167. this.pos = 0
  168. } else {
  169. // 判断当前元素与上一个元素是否相同
  170. if (data[i].deptName === data[i - 1].deptName) {
  171. this.spanArr[this.pos] += 1;
  172. this.spanArr.push(0);
  173. } else {
  174. this.spanArr.push(1);
  175. this.pos = i;
  176. }
  177. }
  178. console.log(this.spanArr)
  179. }
  180. },
  181. // 获取当前时间
  182. getset(){
  183. let date = new Date();
  184. let y = date.getFullYear();
  185. let m = date.getMonth() + 1;
  186. let d = date.getDate();
  187. return y + "-" + m + "-" + d
  188. },
  189. // 获取猪舍
  190. homeNameFormat(row, column) {
  191. return this.selectHomeDataLabel(this.pighomeList,row.pighomeId);
  192. },
  193. zzlbFormat(row, column) {
  194. return this.selectDictLabel(this.zzlbOptions, row.checkZzlb);
  195. },
  196. spdjFormat(row, column) {
  197. return this.selectDictLabel(this.spdjOptions, row.checkSpdj);
  198. },
  199. pzpxFormat(row, column) {
  200. return this.selectDictLabel(this.pzpxOptions, row.pz);
  201. },
  202. // 合并列
  203. objectSpanMethod({row, column, rowIndex, columnIndex}){
  204. let tableData = this.pigletcheckList;
  205. // //rowIndex:行 columnIndex:列
  206. // let {tableData} = this;
  207. console.log(row,column, rowIndex, columnIndex)
  208. if (columnIndex === 0 ) {
  209. const _row = this.spanArr[rowIndex];
  210. const _col = _row > 0 ? 1 : 0;
  211. console.log(`rowspan:${_row} colspan:${_col}`)
  212. return { // [0,0] 表示这一行不显示, [2,1]表示行的合并数
  213. rowspan: _row,
  214. colspan: _col
  215. }
  216. }
  217. },
  218. // 取消按钮
  219. cancel() {
  220. this.open = false;
  221. this.reset();
  222. },
  223. // 表单重置
  224. reset() {
  225. this.form = {
  226. checkId: null,
  227. pighomeId: null,
  228. homeName: null,
  229. pigcolumId: null,
  230. columName: null,
  231. checkBatch: null,
  232. checkPzpx: null,
  233. checkZzlb: null,
  234. checkSpdj: null,
  235. checkPd: null,
  236. checkEndday: null,
  237. checkPcts: null,
  238. checkPdzl: null,
  239. createDeptid: null,
  240. createDeptname: null,
  241. status: "0",
  242. createBy: null,
  243. createTime: null,
  244. updateBy: null,
  245. updateTime: null,
  246. remark: null
  247. };
  248. this.resetForm("form");
  249. },
  250. /** 搜索按钮操作 */
  251. handleQuery(data) {
  252. console.log(data,9876)
  253. console.log(this.queryParams,987)
  254. this.queryParams.condition.deptId = data.condition.deptId
  255. this.queryParams.condition.secondaryGroup = data.condition.secondaryGroup
  256. this.queryParams.condition.thirdGroup = data.condition.thirdGroup
  257. this.queryParams.condition.primaryGroup = data.condition.primaryGroup
  258. this.queryParams.condition.startTime = data.condition.startTime
  259. if(data.condition.pigPzpx !== undefined && data.condition.pigPzpx !== null){
  260. this.queryParams.condition.pigPzpx = data.condition.pigPzpx.join(',')
  261. }
  262. if(data.condition.endTime !== undefined ){
  263. this.queryParams.condition.endTime = data.condition.endTime
  264. }
  265. this.getList();
  266. },
  267. /** 重置按钮操作 */
  268. resetQuery(data) {
  269. console.log(data,9976)
  270. console.log(this.queryParams,997)
  271. this.queryParams.condition.deptId = data.condition.deptId
  272. this.queryParams.condition.secondaryGroup = data.condition.secondaryGroup
  273. this.queryParams.condition.thirdGroup = data.condition.thirdGroup
  274. this.queryParams.condition.startTime = data.condition.startTime
  275. this.queryParams.condition.primaryGroup = data.condition.primaryGroup
  276. if(data.condition.pigPzpx !== undefined && data.condition.pigPzpx !== null){
  277. this.queryParams.condition.pigPzpx = data.condition.pigPzpx.join(',')
  278. }else{
  279. this.queryParams.condition.pigPzpx = data.condition.pigPzpx
  280. }
  281. // if(data.condition.endTime !== undefined ){
  282. this.queryParams.condition.endTime = this.getset()
  283. // }
  284. this.getList();
  285. // this.handleQuery();
  286. },
  287. // 多选框选中数据
  288. handleSelectionChange(selection) {
  289. this.ids = selection.map(item => item.checkId)
  290. this.single = selection.length!==1
  291. this.multiple = !selection.length
  292. },
  293. /** 新增按钮操作 */
  294. handleAdd() {
  295. this.reset();
  296. this.open = true;
  297. this.title = "添加仔猪育肥猪盘点";
  298. },
  299. /** 修改按钮操作 */
  300. handleUpdate(row) {
  301. this.reset();
  302. const checkId = row.checkId || this.ids
  303. getPigletcheck(checkId).then(response => {
  304. this.form = response.data;
  305. this.open = true;
  306. this.title = "修改仔猪育肥猪盘点";
  307. });
  308. },
  309. /** 提交按钮 */
  310. submitForm() {
  311. this.$refs["form"].validate(valid => {
  312. if (valid) {
  313. if (this.form.checkId != null) {
  314. updatePigletcheck(this.form).then(response => {
  315. this.msgSuccess("修改成功");
  316. this.open = false;
  317. this.getList();
  318. });
  319. } else {
  320. addPigletcheck(this.form).then(response => {
  321. this.msgSuccess("新增成功");
  322. this.open = false;
  323. this.getList();
  324. });
  325. }
  326. }
  327. });
  328. },
  329. /** 删除按钮操作 */
  330. handleDelete(row) {
  331. const checkIds = row.checkId || this.ids;
  332. this.$confirm('是否确认删除仔猪育肥猪盘点编号为"' + checkIds + '"的数据项?', "警告", {
  333. confirmButtonText: "确定",
  334. cancelButtonText: "取消",
  335. type: "warning"
  336. }).then(function() {
  337. return delPigletcheck(checkIds);
  338. }).then(() => {
  339. this.getList();
  340. this.msgSuccess("删除成功");
  341. })
  342. },
  343. /** 导出按钮操作 */
  344. handleExport() {
  345. const queryParams = this.queryParams;
  346. this.$confirm('是否确认导出数据?', "警告", {
  347. confirmButtonText: "确定",
  348. cancelButtonText: "取消",
  349. type: "warning"
  350. }).then(function() {
  351. // return exportPigletcheck(queryParams);
  352. }).then(response => {
  353. // this.download(response.msg);
  354. })
  355. },
  356. chahetwo(data) {
  357. console.log(data)
  358. // this.queryParams.villageTowns = data[1];
  359. // this.queryParams.village = data[2];
  360. // this.queryParams.villagerGroup = data[3];
  361. this.queryParams.deptId = data[ data.length - 1]
  362. },
  363. // 打印
  364. handleExportgt(){
  365. this.printExcel("jue")
  366. }
  367. }
  368. };
  369. </script>
  370. <style type="text/css" lang="scss">
  371. .hues{
  372. .el-form-item--medium .el-form-item__label{
  373. width: 42px !important;
  374. }
  375. .el-form-item--medium .el-form-item__content{
  376. width: 80% !important;
  377. }
  378. }
  379. </style>