2e6bee8259e2894c7443285e589e40f0f85777ad.svn-base 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  1. <template>
  2. <div class="app-container" style="position: relative;">
  3. <div v-if="activeName == 'first'" class="operation" style="position: absolute;top: -5px;right: 10px;z-index:1;">
  4. <el-upload v-if="isRoleEdit" style="float: right;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  5. <el-button class="import" icon="el-icon-download" style="float: right;">导入</el-button>
  6. </el-upload>
  7. <el-dropdown style="float: right;margin-right: 10px;">
  8. <el-button class="export" icon="el-icon-upload2">导出</el-button>
  9. <el-dropdown-menu slot="dropdown">
  10. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  11. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  12. </el-dropdown-menu>
  13. </el-dropdown>
  14. </div>
  15. <div v-if="activeName == 'second'" class="operation" style="position: absolute;top: -5px;right: 10px;z-index:1;">
  16. <el-upload v-if="isRoleEdit" style="float: right;" :headers="headers2" :data="uploadData2" :action="uploadExcelUrl2" :show-file-list="false" :before-upload="beforeImport2" :on-success="handleImportSuccess2">
  17. <el-button class="import" style="float: right;" icon="el-icon-download">导入</el-button>
  18. </el-upload>
  19. <el-dropdown style="float: right;margin-right: 10px;">
  20. <el-button class="export" icon="el-icon-upload2">导出</el-button>
  21. <el-dropdown-menu slot="dropdown">
  22. <el-dropdown-item @click.native="handleExport(3)">导出模板</el-dropdown-item>
  23. <el-dropdown-item @click.native="handleExport(4)">导出数据</el-dropdown-item>
  24. </el-dropdown-menu>
  25. </el-dropdown>
  26. </div>
  27. <el-tabs v-model="activeName" @tab-click="handleTabClick">
  28. <el-tab-pane label="体况、粪便评分标准" name="first">
  29. <div class="table1">
  30. <el-table
  31. :key="table1.tableKey"
  32. v-loading="table1.listLoading"
  33. element-loading-text="给我一点时间"
  34. :data="table1.list"
  35. border
  36. fit
  37. highlight-current-row
  38. style="width: 100%;"
  39. :row-style="rowStyle"
  40. :cell-style="cellStyle"
  41. class="elTable table-fixed"
  42. >
  43. <el-table-column label="序号" align="center" type="index" width="50px" />
  44. <el-table-column label="配方名称" min-width="130px" align="center">
  45. <template slot-scope="scope">
  46. <span>{{ scope.row.ftname }}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="体况评分标准" align="center" min-width="300px">
  50. <el-table-column label="体况评分标准(分)" min-width="80px" align="center">
  51. <template slot-scope="scope">
  52. <span>{{ scope.row.bodystandard }}</span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="数据来源" min-width="80px" align="center">
  56. <template slot-scope="scope">
  57. <span>{{ scope.row.bodysource }}</span>
  58. </template>
  59. </el-table-column>
  60. </el-table-column>
  61. <el-table-column label="粪便评分标准" align="center" min-width="300px">
  62. <el-table-column label="粪便评分标准(分)" min-width="80px" align="center">
  63. <template slot-scope="scope">
  64. <span>{{ scope.row.dungstandard }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="数据来源" min-width="80px" align="center">
  68. <template slot-scope="scope">
  69. <span>{{ scope.row.dungsource }}</span>
  70. </template>
  71. </el-table-column>
  72. </el-table-column>
  73. <el-table-column label="操作" align="center" width="50" class-name="small-padding fixed-width" fixed="right">
  74. <template slot-scope="{row}">
  75. <el-button v-if="isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  76. </template>
  77. </el-table-column>
  78. </el-table>
  79. </div>
  80. </el-tab-pane>
  81. <el-tab-pane label="宾州筛、粪便筛标准范围" name="second">
  82. <div class="table2">
  83. <el-table
  84. :key="table2.tableKey"
  85. v-loading="table2.listLoading"
  86. element-loading-text="给我一点时间"
  87. :data="table2.list"
  88. border
  89. fit
  90. highlight-current-row
  91. style="width: 100%;"
  92. :row-style="rowStyle"
  93. :cell-style="cellStyle"
  94. class="elTable table-fixed"
  95. >
  96. <el-table-column label="序号" align="center" type="index" width="50px" />
  97. <el-table-column label="牲畜类别" align="center" min-width="200px">
  98. <el-table-column label="牲畜父类" min-width="80px" align="center">
  99. <template slot-scope="scope">
  100. <span>{{ scope.row.parentname }}</span>
  101. </template>
  102. </el-table-column>
  103. <el-table-column label="牲畜子类" min-width="80px" align="center">
  104. <template slot-scope="scope">
  105. <span>{{ scope.row.cowname }}</span>
  106. </template>
  107. </el-table-column>
  108. </el-table-column>
  109. <el-table-column label="宾州筛" align="center" min-width="200px">
  110. <el-table-column label="宾州筛一层(%)" min-width="80px" align="center">
  111. <template slot-scope="scope">
  112. <span>{{ scope.row.bzonemin }} - {{ scope.row.bzonemax }}</span>
  113. </template>
  114. </el-table-column>
  115. <el-table-column label="宾州筛二层(%)" min-width="80px" align="center">
  116. <template slot-scope="scope">
  117. <span>{{ scope.row.bztwomin }} - {{ scope.row.bztwomax }}</span>
  118. </template>
  119. </el-table-column>
  120. <el-table-column label="宾州筛三层(%)" min-width="80px" align="center">
  121. <template slot-scope="scope">
  122. <span>{{ scope.row.bzthreemin }} - {{ scope.row.bzthreemax }}</span>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="宾州筛四层(%)" min-width="80px" align="center">
  126. <template slot-scope="scope">
  127. <span>{{ scope.row.bzfourmin }} - {{ scope.row.bzfourmax }}</span>
  128. </template>
  129. </el-table-column>
  130. <el-table-column label="数据来源" min-width="80px" align="center">
  131. <template slot-scope="scope">
  132. <span>{{ scope.row.bzsource }}</span>
  133. </template>
  134. </el-table-column>
  135. </el-table-column>
  136. <el-table-column label="粪便筛" align="center" min-width="300px">
  137. <el-table-column label="粪便筛一层(%)" min-width="80px" align="center">
  138. <template slot-scope="scope">
  139. <span>{{ scope.row.fbonemin }} - {{ scope.row.fbonemax }}</span>
  140. </template>
  141. </el-table-column>
  142. <el-table-column label="粪便筛二层(%)" min-width="80px" align="center">
  143. <template slot-scope="scope">
  144. <span>{{ scope.row.fbtwomin }} - {{ scope.row.fbtwomax }}</span>
  145. </template>
  146. </el-table-column>
  147. <el-table-column label="粪便筛三层(%)" min-width="80px" align="center">
  148. <template slot-scope="scope">
  149. <span>{{ scope.row.fbthreemin }} - {{ scope.row.fbthreemax }}</span>
  150. </template>
  151. </el-table-column>
  152. <el-table-column label="数据来源" min-width="80px" align="center">
  153. <template slot-scope="scope">
  154. <span>{{ scope.row.fbsource }}</span>
  155. </template>
  156. </el-table-column>
  157. </el-table-column>
  158. <el-table-column label="操作" align="center" width="50" class-name="small-padding fixed-width" fixed="right">
  159. <template slot-scope="{row}">
  160. <el-button v-if="isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  161. </template>
  162. </el-table-column>
  163. </el-table>
  164. </div>
  165. </el-tab-pane>
  166. </el-tabs>
  167. <!-- 体况、粪便评分标准 -->
  168. <el-dialog :title="textMap[table1.dialogStatus]" :visible.sync="table1.dialogFormVisible" :close-on-click-modal="false" width="80%">
  169. <div class="app-add">
  170. <el-form ref="temp" :rules="table1.rules" :model="table1.temp" label-position="right" label-width="160px" style="width: 90%;margin:0 auto 50px">
  171. <el-row>
  172. <el-col :span="12">
  173. <h3 style="width: 160px;float: left;">配方</h3>
  174. </el-col>
  175. </el-row>
  176. <el-row>
  177. <el-col :span="12">
  178. <el-form-item label="配方名称:" prop="ftname">
  179. <span>{{ table1.temp.ftname }}</span>
  180. </el-form-item>
  181. </el-col>
  182. </el-row>
  183. <el-row>
  184. <el-col :span="12">
  185. <h3 style="width: 160px;float: left;">体况评分标准</h3>
  186. </el-col>
  187. </el-row>
  188. <el-row>
  189. <el-col :span="12">
  190. <el-form-item label="体况评分标准(分):" prop="bodystandard">
  191. <el-select v-model="table1.temp.bodystandard" filterable placeholder="评分标准" class="filter-item" style="width: 100%;">
  192. <el-option v-for="item in physicalList" :key="item.value" :label="item.label" :value="item.label" />
  193. </el-select>
  194. </el-form-item>
  195. </el-col>
  196. <el-col :span="12">
  197. <el-form-item label="数据来源:" prop="bodysource">
  198. <el-input v-model="table1.temp.bodysource" type="textarea" placeholder="1-255字符":autosize="{ minRows: 1, maxRows: 4}" style="width:100%;" maxlength="255" />
  199. </el-form-item>
  200. </el-col>
  201. </el-row>
  202. <el-row>
  203. <el-col :span="12">
  204. <h3 style="width: 160px;float: left;">粪便评分标准</h3>
  205. </el-col>
  206. </el-row>
  207. <el-row>
  208. <el-col :span="12">
  209. <el-form-item label="粪便评分标准(分):" prop="dungstandard">
  210. <el-select v-model="table1.temp.dungstandard" filterable placeholder="粪便评分标准" class="filter-item" style="width: 100%;">
  211. <el-option v-for="item in faecesList" :key="item.value" :label="item.label" :value="item.value" />
  212. </el-select>
  213. </el-form-item>
  214. </el-col>
  215. <el-col :span="12">
  216. <el-form-item label="数据来源:" prop="dungsource">
  217. <el-input v-model="table1.temp.dungsource" type="textarea" placeholder="1-255字符" :autosize="{ minRows: 1, maxRows: 4}" style="width:100%;" maxlength="255" />
  218. </el-form-item>
  219. </el-col>
  220. </el-row>
  221. </el-form>
  222. <div slot="footer" class="dialog-footer">
  223. <el-button class="cancelClose" @click="table1.dialogFormVisible = false;getList() ">关闭</el-button>
  224. <el-button class="save" :disabled="isokDisable" @click="updateData()">确认</el-button>
  225. </div>
  226. </div>
  227. </el-dialog>
  228. <!-- 宾州筛、粪便筛标准范围 -->
  229. <el-dialog :title="textMap[table2.dialogStatus]" :visible.sync="table2.dialogFormVisible" :close-on-click-modal="false" width="80%">
  230. <div class="app-add">
  231. <el-form ref="temp" :rules="table2.rules" :model="table2.temp" label-position="right" label-width="160px" style="width: 90%;margin:0 auto 50px">
  232. <el-row>
  233. <el-col :span="10">
  234. <h3 style="width: 160px;float: left;">牲畜类别</h3>
  235. </el-col>
  236. </el-row>
  237. <el-row>
  238. <el-col :span="10">
  239. <el-form-item label="牲畜父类:" prop="parentname">
  240. <span>{{ table2.temp.parentname }}</span>
  241. </el-form-item>
  242. </el-col>
  243. <el-col :span="10">
  244. <el-form-item label="牲畜子类:" prop="cowname">
  245. <span>{{ table2.temp.cowname }}</span>
  246. </el-form-item>
  247. </el-col>
  248. </el-row>
  249. <el-row>
  250. <el-col :span="10">
  251. <h3 style="width: 160px;float: left;">宾州筛</h3>
  252. </el-col>
  253. </el-row>
  254. <el-row>
  255. <el-col :span="10">
  256. <el-form-item label="宾州筛一层(%):">
  257. <el-input-number v-model="table2.temp.bzonemin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
  258. <span style="width: 1%;">——</span>
  259. <el-input-number v-model="table2.temp.bzonemax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
  260. </el-form-item>
  261. </el-col>
  262. <el-col :span="10">
  263. <el-form-item label="宾州筛二层(%):">
  264. <el-input-number v-model="table2.temp.bztwomin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
  265. <span style="width: 1%;">——</span>
  266. <el-input-number v-model="table2.temp.bztwomax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
  267. </el-form-item>
  268. </el-col>
  269. </el-row>
  270. <el-row>
  271. <el-col :span="10">
  272. <el-form-item label="宾州筛三层(%):">
  273. <el-input-number v-model="table2.temp.bzthreemin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
  274. <span style="width: 1%;">——</span>
  275. <el-input-number v-model="table2.temp.bzthreemax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
  276. </el-form-item>
  277. </el-col>
  278. <el-col :span="10">
  279. <el-form-item label="宾州筛四层(%):">
  280. <el-input-number v-model="table2.temp.bzfourmin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
  281. <span style="width: 1%;">——</span>
  282. <el-input-number v-model="table2.temp.bzfourmax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
  283. </el-form-item>
  284. </el-col>
  285. </el-row>
  286. <el-row>
  287. <el-col :span="10">
  288. <el-form-item label="数据来源:" prop="bzsource">
  289. <el-input v-model="table2.temp.bzsource" type="textarea" placeholder="1-255字符" :autosize="{ minRows: 1, maxRows: 4}" style="width:100%;" maxlength="255" />
  290. </el-form-item>
  291. </el-col>
  292. </el-row>
  293. <el-row>
  294. <el-col :span="10">
  295. <h3 style="width: 160px;float: left;">粪便筛</h3>
  296. </el-col>
  297. </el-row>
  298. <el-row>
  299. <el-col :span="10">
  300. <el-form-item label="粪便筛一层(%):">
  301. <el-input-number v-model="table2.temp.fbonemin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
  302. <span style="width: 1%;">——</span>
  303. <el-input-number v-model="table2.temp.fbonemax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
  304. </el-form-item>
  305. </el-col>
  306. <el-col :span="10">
  307. <el-form-item label="粪便筛二层(%):">
  308. <el-input-number v-model="table2.temp.fbtwomin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
  309. <span style="width: 1%;">——</span>
  310. <el-input-number v-model="table2.temp.fbtwomax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
  311. </el-form-item>
  312. </el-col>
  313. </el-row>
  314. <el-row>
  315. <el-col :span="10">
  316. <el-form-item label="粪便筛三层(%):">
  317. <el-input-number v-model="table2.temp.fbthreemin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
  318. <span style="width: 1%;">——</span>
  319. <el-input-number v-model="table2.temp.fbthreemax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
  320. </el-form-item>
  321. </el-col>
  322. <el-col :span="10">
  323. <el-form-item label="数据来源:" prop="fbsource">
  324. <el-input v-model="table2.temp.fbsource" type="textarea" placeholder="1-255字符" :autosize="{ minRows: 1, maxRows: 4}" style="width:100%;" maxlength="255" />
  325. </el-form-item>
  326. </el-col>
  327. </el-row>
  328. </el-form>
  329. <div slot="footer" class="dialog-footer">
  330. <el-button class="cancelClose" @click="table2.dialogFormVisible = false; getList2()">关闭</el-button>
  331. <el-button class="save" :disabled="isokDisable" @click="updateData()">确认</el-button>
  332. </div>
  333. </div>
  334. </el-dialog>
  335. </div>
  336. </el-tab-pane></el-tabs></div></template>
  337. <script>
  338. import { GetDataByName, PostDataByName, failproccess, GetDataByNames, checkButtons } from '@/api/common'
  339. import Cookies from 'js-cookie'
  340. import axios from 'axios'
  341. import { parseTime, json2excel } from '@/utils/index.js'
  342. import { getToken } from '@/utils/auth'
  343. export default {
  344. name: 'StandardParameters',
  345. data() {
  346. return {
  347. isRoleEdit: [],
  348. activeName: 'first',
  349. requestParams: [
  350. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['评分标准'] },
  351. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['粪便评分标准'] }
  352. ],
  353. physicalList: [], // 标准体况评分
  354. faecesList: [], // 标准粪便评分
  355. table1: {
  356. getdataListParm: {
  357. name: 'getOptscoreList',
  358. page: 1,
  359. offset: 1,
  360. returntype: 'Map',
  361. parammaps: {
  362. pastureid: Cookies.get('pastureid'),
  363. enable: ''
  364. }
  365. },
  366. tableKey: 0,
  367. list: [],
  368. total: 0,
  369. listLoading: true,
  370. // 编辑
  371. dialogFormVisible: false,
  372. dialogStatus: '',
  373. temp: {},
  374. rules: {
  375. bodystandard: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  376. dungstandard: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  377. }
  378. },
  379. table2: {
  380. getdataListParm: {
  381. name: 'getOptrangeList',
  382. page: 1,
  383. offset: 1,
  384. returntype: 'Map',
  385. parammaps: {
  386. pastureid: Cookies.get('pastureid')
  387. }
  388. },
  389. tableKey: 0,
  390. list: [],
  391. total: 0,
  392. listLoading: true,
  393. // 编辑
  394. dialogFormVisible: false,
  395. dialogStatus: '',
  396. temp: {},
  397. rules: {}
  398. },
  399. download: {
  400. getdataListParm: {},
  401. list: []
  402. },
  403. textMap: {
  404. update: '编辑'
  405. },
  406. requestParam: {},
  407. isokDisable: false,
  408. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  409. cellStyle: { padding: 0 + 'px' }
  410. }
  411. },
  412. computed: {
  413. // 设置请求头
  414. headers() {
  415. return {
  416. token: getToken()
  417. }
  418. },
  419. uploadData() {
  420. return {
  421. name: 'checkft,updateOptscoreUpload',
  422. importParams: '配方名称,体况评分标准(分),体况评分数据来源,粪便评分标准(分),粪便评分数据来源',
  423. sheetname: 'Sheet1',
  424. // 登录牧场
  425. pastureid: Cookies.get('pastureid'),
  426. // 日期参数
  427. dateParams: '',
  428. // 必填参数
  429. requiredParams: '配方名称,体况评分标准(分),粪便评分标准(分)',
  430. // 为数值的参数
  431. numParams: '体况评分标准(分),粪便评分标准(分)'
  432. }
  433. },
  434. // 设置上传地址
  435. uploadExcelUrl() {
  436. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  437. },
  438. headers2() {
  439. return {
  440. token: getToken()
  441. }
  442. },
  443. uploadData2() {
  444. return {
  445. name: 'checkbigcowclassW,checkclassnameW,insertOptrangeUpload',
  446. importParams: '牲畜父类,牲畜子类,宾州筛一层(%),宾州筛二层(%),宾州筛三层(%),宾州筛四层(%),宾州筛数据来源,粪便筛一层(%),粪便筛二层(%),粪便筛三层(%),粪便筛数据来源',
  447. sheetname: 'Sheet1',
  448. // 登录牧场
  449. pastureid: Cookies.get('pastureid'),
  450. // 日期参数
  451. dateParams: '',
  452. // 必填参数
  453. requiredParams: '牲畜父类,牲畜子类',
  454. // 为数值的参数
  455. numParams: ''
  456. }
  457. },
  458. // 设置上传地址
  459. uploadExcelUrl2() {
  460. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  461. }
  462. },
  463. created() {
  464. this.getList()
  465. this.getDownList()
  466. this.getButtons()
  467. },
  468. methods: {
  469. getButtons() {
  470. const Edit = 'StandardParameters'
  471. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  472. this.isRoleEdit = isRoleEdit
  473. },
  474. getDownList() {
  475. GetDataByNames(this.requestParams).then(response => {
  476. this.physicalList = response.data.getDictByName.list
  477. this.faecesList = response.data.getDictByName2.list
  478. })
  479. },
  480. handleTabClick(tab, event) {
  481. console.log(tab, event)
  482. if (tab.name === 'first') {
  483. this.getList()
  484. } else if (tab.name === 'second') {
  485. this.getList2()
  486. }
  487. },
  488. getList() {
  489. this.table1.listLoading = true
  490. GetDataByName(this.table1.getdataListParm).then(response => {
  491. console.log('table1数据', response.data.list)
  492. if (response.data.list !== null) {
  493. this.table1.list = response.data.list
  494. this.table1.total = response.data.total
  495. } else {
  496. this.table1.list = []
  497. }
  498. setTimeout(() => {
  499. this.table1.listLoading = false
  500. }, 100)
  501. })
  502. },
  503. getList2() {
  504. this.table2.listLoading = true
  505. GetDataByName(this.table2.getdataListParm).then(response => {
  506. console.log('table1数据', response.data.list)
  507. if (response.data.list !== null) {
  508. this.table2.list = response.data.list
  509. if (response.data.total) {
  510. this.table2.total = response.data.total
  511. }
  512. } else {
  513. this.table2.list = []
  514. }
  515. setTimeout(() => {
  516. this.table2.listLoading = false
  517. }, 100)
  518. })
  519. },
  520. // 编辑
  521. handleUpdate(row) {
  522. if (this.activeName === 'first') {
  523. console.log('点击了体况、粪便评分标准编辑')
  524. this.table1.dialogStatus = 'update'
  525. this.table1.dialogFormVisible = true
  526. this.table1.temp = Object.assign({}, row)
  527. } else if (this.activeName === 'second') {
  528. console.log('点击了宾州筛、粪便筛标准范围编辑')
  529. this.table2.dialogStatus = 'update'
  530. this.table2.dialogFormVisible = true
  531. this.table2.temp = Object.assign({}, row)
  532. }
  533. },
  534. updateData() {
  535. if (this.activeName === 'first') {
  536. console.log('点击了体况、粪便评分标准编辑保存')
  537. this.isokDisable = true
  538. setTimeout(() => {
  539. this.isokDisable = false
  540. }, 1000)
  541. this.$refs['temp'].validate(valid => {
  542. if (valid) {
  543. this.requestParam.name = 'updateOptscore'
  544. this.requestParam.parammaps = this.table1.temp
  545. PostDataByName(this.requestParam).then(response => {
  546. console.log('新增保存发送参数', this.requestParam)
  547. if (response.msg !== 'fail') {
  548. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  549. this.table1.dialogFormVisible = false
  550. this.getList()
  551. } else {
  552. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  553. }
  554. })
  555. }
  556. })
  557. } else if (this.activeName === 'second') {
  558. console.log('点击了宾州筛、粪便筛标准范围编辑保存')
  559. this.isokDisable = true
  560. setTimeout(() => {
  561. this.isokDisable = false
  562. }, 1000)
  563. // 若最小值大于最大值
  564. if (parseFloat(this.table2.temp.bzonemin) > parseFloat(this.table2.temp.bzonemax)) {
  565. this.$message({ type: 'error', message: '宾州筛一层最大值不可小于等于最小值', duration: 2000 })
  566. return false
  567. }
  568. if (parseFloat(this.table2.temp.bztwomin) > parseFloat(this.table2.temp.bztwomax)) {
  569. this.$message({ type: 'error', message: '宾州筛二层最大值不可小于等于最小值', duration: 2000 })
  570. return false
  571. }
  572. if (parseFloat(this.table2.temp.bzthreemin) > parseFloat(this.table2.temp.bzthreemax)) {
  573. this.$message({ type: 'error', message: '宾州筛三层最大值不可小于等于最小值', duration: 2000 })
  574. return false
  575. }
  576. if (parseFloat(this.table2.temp.bzfourmin) > parseFloat(this.table2.temp.bzfourmax)) {
  577. this.$message({ type: 'error', message: '宾州筛四层最大值不可小于等于最小值', duration: 2000 })
  578. return false
  579. }
  580. if (parseFloat(this.table2.temp.fbonemin) > parseFloat(this.table2.temp.fbonemax)) {
  581. this.$message({ type: 'error', message: '粪便筛一层最大值不可小于等于最小值', duration: 2000 })
  582. return false
  583. }
  584. if (parseFloat(this.table2.temp.fbtwomin) > parseFloat(this.table2.temp.fbtwomax)) {
  585. this.$message({ type: 'error', message: '粪便筛二层最大值不可小于等于最小值', duration: 2000 })
  586. return false
  587. }
  588. if (parseFloat(this.table2.temp.fbthreemin) > parseFloat(this.table2.temp.fbthreemax)) {
  589. this.$message({ type: 'error', message: '粪便筛三层最大值不可小于等于最小值', duration: 2000 })
  590. return false
  591. }
  592. // 若最大值最小值为空
  593. if (this.table2.temp.bzonemin == '' || this.table2.temp.bzonemin == undefined) { this.table2.temp.bzonemin = '0' }
  594. if (this.table2.temp.bzonemax == '' || this.table2.temp.bzonemax == undefined) { this.table2.temp.bzonemax = '0' }
  595. if (this.table2.temp.bztwomin == '' || this.table2.temp.bztwomin == undefined) { this.table2.temp.bztwomin = '0' }
  596. if (this.table2.temp.bztwomax == '' || this.table2.temp.bztwomax == undefined) { this.table2.temp.bztwomax = '0' }
  597. if (this.table2.temp.bzthreemin == '' || this.table2.temp.bzthreemin == undefined) { this.table2.temp.bzthreemin = '0' }
  598. if (this.table2.temp.bzthreemax == '' || this.table2.temp.bzthreemax == undefined) { this.table2.temp.bzthreemax = '0' }
  599. if (this.table2.temp.bzfourmin == '' || this.table2.temp.bzfourmin == undefined) { this.table2.temp.bzfourmin = '0' }
  600. if (this.table2.temp.bzfourmax == '' || this.table2.temp.bzfourmax == undefined) { this.table2.temp.bzfourmax = '0' }
  601. if (this.table2.temp.fbonemin == '' || this.table2.temp.fbonemin == undefined) { this.table2.temp.fbonemin = '0' }
  602. if (this.table2.temp.fbonemax == '' || this.table2.temp.fbonemax == undefined) { this.table2.temp.fbonemax = '0' }
  603. if (this.table2.temp.fbtwomin == '' || this.table2.temp.fbtwomin == undefined) { this.table2.temp.fbtwomin = '0' }
  604. if (this.table2.temp.fbtwomax == '' || this.table2.temp.fbtwomax == undefined) { this.table2.temp.fbtwomax = '0' }
  605. if (this.table2.temp.fbthreemin == '' || this.table2.temp.fbthreemin == undefined) { this.table2.temp.fbthreemin = '0' }
  606. if (this.table2.temp.fbthreemax == '' || this.table2.temp.fbthreemax == undefined) { this.table2.temp.fbthreemax = '0' }
  607. var positiveInteger = /^([0-9]{1,2}|100)$/
  608. if (!positiveInteger.test(parseFloat(this.table2.temp.bzonemin))) {
  609. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  610. return false
  611. }
  612. if (!positiveInteger.test(parseFloat(this.table2.temp.bzonemax))) {
  613. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  614. return false
  615. }
  616. if (!positiveInteger.test(parseFloat(this.table2.temp.bztwomin))) {
  617. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  618. return false
  619. }
  620. if (!positiveInteger.test(parseFloat(this.table2.temp.bztwomax))) {
  621. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  622. return false
  623. }
  624. if (!positiveInteger.test(parseFloat(this.table2.temp.bzthreemin))) {
  625. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  626. return false
  627. }
  628. if (!positiveInteger.test(parseFloat(this.table2.temp.bzthreemax))) {
  629. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  630. return false
  631. }
  632. if (!positiveInteger.test(parseFloat(this.table2.temp.bzfourmin))) {
  633. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  634. return false
  635. }
  636. if (!positiveInteger.test(parseFloat(this.table2.temp.bzfourmax))) {
  637. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  638. return false
  639. }
  640. if (!positiveInteger.test(parseFloat(this.table2.temp.fbonemin))) {
  641. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  642. return false
  643. }
  644. if (!positiveInteger.test(parseFloat(this.table2.temp.fbonemax))) {
  645. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  646. return false
  647. }
  648. if (!positiveInteger.test(parseFloat(this.table2.temp.fbtwomin))) {
  649. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  650. return false
  651. }
  652. if (!positiveInteger.test(parseFloat(this.table2.temp.fbtwomax))) {
  653. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  654. return false
  655. }
  656. if (!positiveInteger.test(parseFloat(this.table2.temp.fbthreemin))) {
  657. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  658. return false
  659. }
  660. if (!positiveInteger.test(parseFloat(this.table2.temp.fbthreemin))) {
  661. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  662. return false
  663. }
  664. this.requestParam.name = 'insertOptrange'
  665. this.requestParam.parammaps = this.table2.temp
  666. this.$refs['temp'].validate(valid => {
  667. if (valid) {
  668. PostDataByName(this.requestParam).then(response => {
  669. console.log('新增保存发送参数', this.requestParam)
  670. if (response.msg !== 'fail') {
  671. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  672. this.table2.dialogFormVisible = false
  673. this.getList2()
  674. this.activeName = 'second'
  675. } else {
  676. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  677. if (this.table2.temp.bzonemin == '0') { this.table2.temp.bzonemin = '' }
  678. if (this.table2.temp.bzonemax == '0') { this.table2.temp.bzonemax = '' }
  679. if (this.table2.temp.bztwomin == '0') { this.table2.temp.bztwomin = '' }
  680. if (this.table2.temp.bztwomax == '0') { this.table2.temp.bztwomax = '' }
  681. if (this.table2.temp.bzthreemin == '0') { this.table2.temp.bzthreemin = '' }
  682. if (this.table2.temp.bzthreemax == '0') { this.table2.temp.bzthreemax = '' }
  683. if (this.table2.temp.bzfourmin == '0') { this.table2.temp.bzfourmin = '' }
  684. if (this.table2.temp.bzfourmax == '0') { this.table2.temp.bzfourmax = '' }
  685. if (this.table2.temp.fbonemin == '0') { this.table2.temp.fbonemin = '' }
  686. if (this.table2.temp.fbonemax == '0') { this.table2.temp.fbonemax = '' }
  687. if (this.table2.temp.fbtwomin == '0') { this.table2.temp.fbtwomin = '' }
  688. if (this.table2.temp.fbtwomax == '0') { this.table2.temp.fbtwomax = '' }
  689. if (this.table2.temp.fbthreemin == '0') { this.table2.temp.fbthreemin = '' }
  690. if (this.table2.temp.fbthreemax == '0') { this.table2.temp.fbthreemax = '' }
  691. }
  692. })
  693. }
  694. })
  695. }
  696. },
  697. // 导出
  698. handleExport(item) {
  699. if (item == 1) {
  700. console.log('体况、粪便评分标准/导出')
  701. var downloadList = [
  702. { 'obj1': '1、文件类型为xlsx类型,对应表格文件名格式为:文件名称.xlsx;' },
  703. { 'obj1': '2、底部工作表名称不可更改,默认为:Sheet1;' },
  704. { 'obj1': '3、配方名称,体况评分标准(分),粪便评分标准为必填;' },
  705. { 'obj1': '4、配方名称必须与系统中配方模板的配方名称匹配;' },
  706. { 'obj1': '5、标准分数为固定几个分值,分别为:2.75-,2.75,3,3.25,3.75,4+;粪便评分标准为1,2,3,4,5' },
  707. { 'obj1': '6、数据最多可导入200条,超过200条请分多个文件导入。' }
  708. ]
  709. var excelDatas = [
  710. {
  711. tHeader: ['配方名称', '体况评分标准(分)', '体况评分数据来源', '粪便评分标准(分)', '粪便评分数据来源'],
  712. filterVal: ['ftname', '', '', '', ''],
  713. tableDatas: this.table1.list,
  714. sheetName: 'Sheet1'
  715. }, {
  716. tHeader: ['填写规范:'],
  717. filterVal: ['obj1'],
  718. tableDatas: downloadList,
  719. sheetName: 'Sheet2'
  720. }
  721. ]
  722. json2excel(excelDatas, '基础数据_体况、粪便评分标准导入模板', true, 'xlsx')
  723. } else if (item == 3) {
  724. console.log('宾州筛、粪便筛标准范围/导出')
  725. this.download.getdataListParm.name = 'getOptrangeList'
  726. this.download.getdataListParm.parammaps = {}
  727. this.download.getdataListParm.parammaps.pastureid = Cookies.get('pastureid')
  728. GetDataByName(this.download.getdataListParm).then(response => {
  729. if (response.data.list !== null) {
  730. this.download.list = response.data.list
  731. } else {
  732. this.download.list = []
  733. }
  734. var downloadList = [
  735. { 'obj1': '1、文件类型为xlsx类型,对应表格文件名格式为:文件名称.xlsx;' },
  736. { 'obj1': '2、底部工作表名称不可更改,默认为:Sheet1;' },
  737. { 'obj1': '3、牲畜父类,牲畜子类为必填;' },
  738. { 'obj1': '4、牲畜类别必须与系统基础数据中牲畜类别匹配;' },
  739. { 'obj1': '5、数据最多可导入200条,超过200条请分多个文件导入。' }
  740. ]
  741. var excelDatas = [
  742. {
  743. tHeader: ['牲畜父类', '牲畜子类', '宾州筛一层(%)', '宾州筛二层(%)', '宾州筛三层(%)', '宾州筛四层(%)', '宾州筛数据来源', '粪便筛一层(%)', '粪便筛二层(%)', '粪便筛三层(%)', '粪便筛数据来源'],
  744. filterVal: ['parentname', 'cowname', '', '', '', '', '', '', '', '', ''],
  745. tableDatas: this.download.list,
  746. sheetName: 'Sheet1'
  747. }, {
  748. tHeader: ['填写规范:'],
  749. filterVal: ['obj1'],
  750. tableDatas: downloadList,
  751. sheetName: 'Sheet2'
  752. }
  753. ]
  754. json2excel(excelDatas, '基础数据_宾州筛、粪便筛标准范围导入模板', true, 'xlsx')
  755. })
  756. } else if (item == 2) {
  757. console.log('体况评分导出数据', this.table1.list)
  758. import('@/vendor/Export5Excel').then(excel => {
  759. const multiHeader = [
  760. ['配方名称', '体况评分标准', '', '粪便评分标准', '']
  761. ]
  762. const multiHeader2 = [
  763. ['', '体况评分标准(分)', '数据来源', '粪便评分标准(分)', '数据来源']
  764. ]
  765. const filterVal = ['ftname', 'bodystandard', 'bodysource', 'dungstandard', 'dungsource']
  766. const data = this.table1.list.map((v) => filterVal.map((j) => v[j]))
  767. const merges = ['A1:A2', 'B1:C1', 'D1:E1']
  768. excel.export_json_to_excel({ multiHeader, multiHeader2, data, filename: '体况、粪便评分标准导出数据', merges })
  769. })
  770. } else if (item == 4) {
  771. var downList = []
  772. for (let i = 0; i < this.table2.list.length; i++) {
  773. var obj = {}
  774. obj.parentname = this.table2.list[i].parentname
  775. obj.cowname = this.table2.list[i].cowname
  776. obj.bzsource = this.table2.list[i].bzsource
  777. if (this.table2.list[i].bzonemin == undefined) { this.table2.list[i].bzonemin = '' }
  778. if (this.table2.list[i].bzonemax == undefined) { this.table2.list[i].bzonemax = '' }
  779. if (this.table2.list[i].bztwomin == undefined) { this.table2.list[i].bztwomin = '' }
  780. if (this.table2.list[i].bztwomax == undefined) { this.table2.list[i].bztwomax = '' }
  781. if (this.table2.list[i].bzthreemin == undefined) { this.table2.list[i].bzthreemin = '' }
  782. if (this.table2.list[i].bzthreemax == undefined) { this.table2.list[i].bzthreemax = '' }
  783. if (this.table2.list[i].bzfourmin == undefined) { this.table2.list[i].bzfourmin = '' }
  784. if (this.table2.list[i].bzfourmax == undefined) { this.table2.list[i].bzfourmax = '' }
  785. if (this.table2.list[i].fbonemin == undefined) { this.table2.list[i].fbonemin = '' }
  786. if (this.table2.list[i].fbonemax == undefined) { this.table2.list[i].fbonemax = '' }
  787. if (this.table2.list[i].fbtwomin == undefined) { this.table2.list[i].fbtwomin = '' }
  788. if (this.table2.list[i].fbtwomax == undefined) { this.table2.list[i].fbtwomax = '' }
  789. if (this.table2.list[i].fbthreemin == undefined) { this.table2.list[i].fbthreemin = '' }
  790. if (this.table2.list[i].fbthreemax == undefined) { this.table2.list[i].fbthreemax = '' }
  791. obj.one1 = this.table2.list[i].bzonemin + '-' + this.table2.list[i].bzonemax
  792. obj.two1 = this.table2.list[i].bztwomin + '-' + this.table2.list[i].bztwomax
  793. obj.three1 = this.table2.list[i].bzthreemin + '-' + this.table2.list[i].bzthreemax
  794. obj.four1 = this.table2.list[i].bzfourmin + '-' + this.table2.list[i].bzfourmax
  795. obj.one2 = this.table2.list[i].fbonemin + '-' + this.table2.list[i].fbonemax
  796. obj.two2 = this.table2.list[i].fbtwomin + '-' + this.table2.list[i].fbtwomax
  797. obj.three2 = this.table2.list[i].fbthreemin + '-' + this.table2.list[i].fbthreemax
  798. obj.fbsource = this.table2.list[i].fbsource
  799. downList.push(obj)
  800. }
  801. import('@/vendor/Export5Excel').then(excel => {
  802. const multiHeader = [
  803. ['牲畜类别', '', '宾州筛', '', '', '', '', '粪便筛', '', '', '']
  804. ]
  805. const multiHeader2 = [
  806. ['牲畜父类', '牲畜子类', '宾州筛一层(%)', '宾州筛二层(%)', '宾州筛三层(%)', '宾州筛四层(%)', '数据来源', '粪便筛一层(%)', '粪便筛二层(%)', '粪便筛三层(%)', '数据来源']
  807. ]
  808. const filterVal = ['parentname', 'cowname', 'one1', 'two1', 'three1', 'four1', 'bzsource', 'one2', 'two2', 'three2', 'fbsource']
  809. const data = downList.map((v) => filterVal.map((j) => v[j]))
  810. const merges = ['A1:B1', 'C1:G1', 'H1:K1']
  811. excel.export_json_to_excel({ multiHeader, multiHeader2, data, filename: '宾州筛、粪便筛标准范围导出数据', merges })
  812. })
  813. }
  814. },
  815. beforeImport(file) {
  816. const isLt2M = file.size / 1024 / 1024 < 2
  817. if (!isLt2M) {
  818. this.$message.error('上传文件大小不能超过 2MB!')
  819. }
  820. return isLt2M
  821. },
  822. handleImportSuccess(res, file) {
  823. this.getList()
  824. if (res.msg === 'ok') {
  825. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  826. if (res.data.err_count > 0) {
  827. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  828. import('@/vendor/Export2Excel').then(excel => {
  829. const list1 = res.data.result
  830. const tHeader = [
  831. '配方名称', '体况评分标准(分)', '体况评分数据来源', '粪便评分标准(分)', '粪便评分数据来源', '错误信息'
  832. ]
  833. const filterVal = [
  834. '配方名称', '体况评分标准(分)', '体况评分数据来源', '粪便评分标准(分)', '粪便评分数据来源', 'error_msg'
  835. ]
  836. const data1 = this.formatJson(filterVal, list1)
  837. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '体况、粪便评分导入报错信息', autoWidth: true, bookType: 'xlsx' })
  838. })
  839. }
  840. } else {
  841. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  842. }
  843. },
  844. formatJson(filterVal, jsonData) {
  845. return jsonData.map(v =>
  846. filterVal.map(j => {
  847. if (j === 'timestamp') {
  848. return parseTime(v[j])
  849. } else {
  850. return v[j]
  851. }
  852. })
  853. )
  854. },
  855. beforeImport2(file) {
  856. const isLt2M = file.size / 1024 / 1024 < 2
  857. if (!isLt2M) {
  858. this.$message.error('上传文件大小不能超过 2MB!')
  859. }
  860. return isLt2M
  861. },
  862. handleImportSuccess2(res, file) {
  863. this.getList2()
  864. if (res.msg === 'ok') {
  865. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  866. if (res.data.err_count > 0) {
  867. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  868. import('@/vendor/Export2Excel').then(excel => {
  869. const list1 = res.data.result
  870. const tHeader = [
  871. '牲畜父类', '牲畜子类', '宾州筛一层(%)', '宾州筛二层(%)', '宾州筛三层(%)', '宾州筛四层(%)', '宾州筛数据来源', '粪便筛二层(%)', '粪便筛三层(%)', '粪便筛数据来源', '错误信息'
  872. ]
  873. const filterVal = [
  874. '牲畜父类', '牲畜子类', '宾州筛一层(%)', '宾州筛二层(%)', '宾州筛三层(%)', '宾州筛四层(%)', '宾州筛数据来源', '粪便筛二层(%)', '粪便筛三层(%)', '粪便筛数据来源', 'error_msg'
  875. ]
  876. const data1 = this.formatJson2(filterVal, list1)
  877. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '宾州筛、粪便筛导入报错信息', autoWidth: true, bookType: 'xlsx' })
  878. })
  879. }
  880. } else {
  881. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  882. }
  883. },
  884. formatJson2(filterVal, jsonData) {
  885. return jsonData.map(v =>
  886. filterVal.map(j => {
  887. if (j === 'timestamp') {
  888. return parseTime(v[j])
  889. } else {
  890. return v[j]
  891. }
  892. })
  893. )
  894. }
  895. // 导入
  896. // handleImport() {
  897. // if (this.activeName === 'first') {
  898. // console.log('体况、粪便评分标准/导入')
  899. // } else if (this.activeName === 'second') {
  900. // console.log('宾州筛、粪便筛标准范围/导入')
  901. // }
  902. // }
  903. }
  904. }
  905. </script>
  906. <style lang="scss" scoped>
  907. // .operation{
  908. // position: relative;
  909. // height: 50px;
  910. // .export{position: absolute;right: 110px;bottom: 10px;}
  911. // .import{position: absolute;right: 0;bottom: 10px;}
  912. // }
  913. </style>