56c9c2600904da4842af7d5592ff187f0e5de88c.svn-base 92 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926
  1. <template>
  2. <div>
  3. <div class="table">
  4. <el-table
  5. :key="table.tableKey"
  6. v-loading="table.listLoading"
  7. element-loading-text="给我一点时间"
  8. :data="table.list"
  9. border
  10. fit
  11. highlight-current-row
  12. style="width: 100%;"
  13. :row-style="rowStyle"
  14. :cell-style="cellStyle"
  15. class="elTable table-fixed"
  16. @header-click="headerClick"
  17. @cell-click="cellClick"
  18. @selection-change="handleSelect"
  19. >
  20. <el-table-column type="selection" width="50" />
  21. <el-table-column :key="1" label="序号" align="center" type="index" width="50px" class-name="small-padding fixed-width" fixed="left">
  22. <template slot-scope="scope">
  23. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  24. </template>
  25. </el-table-column>
  26. <el-table-column label="栏舍名称" min-width="100px" align="center" class-name="small-padding fixed-width" fixed="left">
  27. <template slot-scope="scope">
  28. <span>{{ scope.row.barname }}</span>
  29. </template>
  30. </el-table-column>
  31. <el-table-column label="软件牛头数" min-width="70px" align="center">
  32. <template slot-scope="scope">
  33. <span>{{ scope.row.softccount }}</span>
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="实际牛头数" min-width="100px" align="center">
  37. <template slot-scope="scope">
  38. <span v-if="scope.row.NoEdit">{{ scope.row.ccount }}</span>
  39. <el-input v-if="scope.row.Edit" v-model="scope.row.ccount" step="0.01" type="number" style="width:95%;padding:10px 0;" @blur="blurCcount(scope.row)" />
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="系数(%)" min-width="100px" align="center">
  43. <template slot-scope="scope">
  44. <span v-if="scope.row.NoEdit">{{ scope.row.ratio }}</span>
  45. <el-input v-if="scope.row.Edit" v-model="scope.row.ratio" step="0.01" type="number" style="width:95%;padding:10px 0;" @blur="blurRatio(scope.row)" />
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="系数头数" min-width="100px" align="center">
  49. <template slot-scope="scope">
  50. <span v-if="scope.row.NoEdit">{{ scope.row.ccountratio }}</span>
  51. <el-input v-if="scope.row.Edit" v-model="scope.row.ccountratio" step="0.01" type="number" style="width:95%;padding:10px 0;" @blur="blurCcountratio(scope.row)" />
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="配方模板" min-width="130px" align="center">
  55. <template slot-scope="scope">
  56. <span v-if="scope.row.NoEdit">{{ scope.row.ftname }}</span>
  57. <el-select v-if="scope.row.Edit" v-model="scope.row.ftid" filterable placeholder="配方模板" class="filter-item" style="width:99%;" @change="(value)=> {changeRecipeTemplate(value, scope.row)}">
  58. <el-option v-for="item in recipeTemplateList" :key="item.id" :label="item.tname" :value="item.id" />
  59. </el-select>
  60. </template>
  61. </el-table-column>
  62. <el-table-column v-if="table.isPtsfname" :key="8" label="补料配方" min-width="130px" align="center">
  63. <template slot-scope="scope">
  64. <span v-if="scope.row.NoEdit">{{ scope.row.ptsfname }}</span>
  65. <el-select v-if="scope.row.Edit" v-model="scope.row.ptsfid" clearable filterable placeholder="补料配方" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFeedingFormula(value, scope.row)}">
  66. <el-option v-for="item in feedingFormulaList" :key="item.id" :label="item.tname" :value="item.id" />
  67. </el-select>
  68. </template>
  69. </el-table-column>
  70. <el-table-column v-if="table.isRW1" :key="9" label="第一班比例(%)" min-width="95px" align="center">
  71. <template slot-scope="scope">
  72. <span v-if="scope.row.NoEdit">{{ scope.row.r1 }}</span>
  73. <el-input v-if="scope.row.Edit" v-model="scope.row.r1" :disabled="scope.row.isOneWeight" step="0.01" type="number" style="width:95%;padding:10px 0;" @blur="blurR(scope.row)" />
  74. </template>
  75. </el-table-column>
  76. <el-table-column v-if="table.isRW1" :key="10" label="第一班重量" min-width="130px" align="center" :render-header="renderHeader">
  77. <template slot-scope="scope">
  78. <span v-if="scope.row.NoEdit">{{ scope.row.w1 }}</span>
  79. <el-input v-if="scope.row.Edit" v-model="scope.row.w1" :disabled="scope.row.isOneWeight" step="0.01" type="number" style="width:95%;padding:10px 0;" @blur="blurW(scope.row)" @focus="focusW(scope.row)" />
  80. </template>
  81. </el-table-column>
  82. <el-table-column v-if="table.isRW2" :key="11" label="第二班比例(%)" min-width="95px" align="center">
  83. <template slot-scope="scope">
  84. <span v-if="scope.row.NoEdit">{{ scope.row.r2 }}</span>
  85. <el-input v-if="scope.row.Edit" v-model="scope.row.r2" step="0.01" type="number" :disabled="scope.row.isTwoWeight" style="width:95%;padding:10px 0;" @blur="blurR(scope.row)" />
  86. </template>
  87. </el-table-column>
  88. <el-table-column v-if="table.isRW2" :key="12" label="第二班重量" min-width="130px" align="center" :render-header="renderHeader">
  89. <template slot-scope="scope">
  90. <span v-if="scope.row.NoEdit">{{ scope.row.w2 }}</span>
  91. <el-input v-if="scope.row.Edit" v-model="scope.row.w2" :disabled="scope.row.isTwoWeight" step="0.01" type="number" style="width:95%;padding:10px 0;" @blur="blurW2(scope.row)" @focus="focusW2(scope.row)" />
  92. </template>
  93. </el-table-column>
  94. <el-table-column v-if="table.isRW3" :key="13" label="第三班比例(%)" min-width="95px" align="center">
  95. <template slot-scope="scope">
  96. <span v-if="scope.row.NoEdit">{{ scope.row.r3 }}</span>
  97. <el-input v-if="scope.row.Edit" v-model="scope.row.r3" step="0.01" type="number" :disabled="scope.row.isThreeWeight" style="width:95%;padding:10px 0;" @blur="blurR(scope.row)" />
  98. </template>
  99. </el-table-column>
  100. <el-table-column v-if="table.isRW3" :key="14" label="第三班重量" min-width="130px" align="center" :render-header="renderHeader">
  101. <template slot-scope="scope">
  102. <span v-if="scope.row.NoEdit">{{ scope.row.w3 }}</span>
  103. <el-input v-if="scope.row.Edit" v-model="scope.row.w3" :disabled="scope.row.isThreeWeight" step="0.01" type="number" style="width:95%;padding:10px 0;" @blur="blurW3(scope.row)" @focus="focusW3(scope.row)" />
  104. </template>
  105. </el-table-column>
  106. <el-table-column v-if="table.isRW4" :key="15" label="第四班比例(%)" min-width="95px" align="center">
  107. <template slot-scope="scope">
  108. <span v-if="scope.row.NoEdit">{{ scope.row.r4 }}</span>
  109. <el-input v-if="scope.row.Edit" v-model="scope.row.r4" step="0.01" type="number" :disabled="scope.row.isFourWeight" style="width:95%;padding:10px 0;" @blur="blurR(scope.row)" />
  110. </template>
  111. </el-table-column>
  112. <el-table-column v-if="table.isRW4" :key="16" label="第四班重量" min-width="130px" align="center" :render-header="renderHeader">
  113. <template slot-scope="scope">
  114. <span v-if="scope.row.NoEdit">{{ scope.row.w4 }}</span>
  115. <el-input v-if="scope.row.Edit" v-model="scope.row.w4" :disabled="scope.row.isFourWeight" step="0.01" type="number" style="width:95%;padding:10px 0;" @blur="blurW4(scope.row)" @focus="focusW4(scope.row)" />
  116. </template>
  117. </el-table-column>
  118. <el-table-column :key="17" label="总比例(%)" min-width="85px" align="center">
  119. <template slot-scope="scope">
  120. <span>{{ scope.row.sumr }}</span>
  121. </template>
  122. </el-table-column>
  123. <el-table-column :key="18" label="投喂量" min-width="80px" align="center">
  124. <template slot-scope="scope">
  125. <span>{{ scope.row.feedweight }}</span>
  126. </template>
  127. </el-table-column>
  128. <el-table-column :key="19" label="配方重量" min-width="90px" align="center">
  129. <template slot-scope="scope">
  130. <span>{{ scope.row.ftweight }}</span>
  131. </template>
  132. </el-table-column>
  133. <el-table-column v-if="table.isPtsfname" :key="20" label="补料重量" min-width="130px" align="center">
  134. <template slot-scope="scope">
  135. <span>{{ scope.row.supplyweight }}</span>
  136. </template>
  137. </el-table-column>
  138. <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width" fixed="right">
  139. <template slot-scope="{row}">
  140. <!-- 编辑 -->
  141. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  142. <!-- 编辑保存 -->
  143. <el-button v-if="row.isUpdateSave" class="miniSuccess" :disabled="isokDisable" @click="updateData(row)">保存</el-button>
  144. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  145. </template>
  146. </el-table-column>
  147. </el-table>
  148. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  149. </div>
  150. </div>
  151. </template>
  152. <script>
  153. import { GetDataByName, GETNurJudge, GetDataByNames, compareSort, ExecDataByConfig, failproccess, PostDataByName, formatNum } from '@/api/common'
  154. import Pagination from '@/components/Pagination'
  155. import { parseTime, json2excel } from '@/utils/index.js'
  156. import { MessageBox } from 'element-ui'
  157. import Cookies from 'js-cookie'
  158. import { getToken } from '@/utils/auth'
  159. export default {
  160. name: 'DhedFormula',
  161. inject: ['reload'],
  162. name: 'DhedFormula',
  163. components: { Pagination },
  164. props: {
  165. show: { type: Boolean, default: false },
  166. parentDate: {
  167. type: String,
  168. defalut: ''
  169. }
  170. },
  171. data() {
  172. return {
  173. date: '',
  174. requestParams: [
  175. { name: 'getFTSWList', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  176. { name: 'getFTBLList', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  177. { name: 'getCowclassListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  178. ],
  179. recipeTemplateList: [], // 配方模板
  180. feedingFormulaList: [], // 补料配方
  181. livestockTypeList: [], // 类别
  182. rules: {
  183. cowclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  184. },
  185. table: {
  186. getdataListParm: {
  187. name: 'getFPList',
  188. page: 1,
  189. offset: 1,
  190. pagecount: 10,
  191. returntype: 'Map',
  192. parammaps: {
  193. pastureid: Cookies.get('pastureid'),
  194. enable: ''
  195. }
  196. },
  197. tableKey: 0,
  198. list: [],
  199. total: 0,
  200. listLoading: true,
  201. temp: {},
  202. rwList: [],
  203. isPtsfname: false, // 补料配方/补料重量
  204. getdataListParm2: {
  205. name: 'getSysoptEnable',
  206. page: 1,
  207. offset: 1,
  208. pagecount: 1,
  209. returntype: 'Map',
  210. parammaps: {
  211. pastureid: Cookies.get('pastureid'),
  212. inforname: 'isEnableSupplyFeed'
  213. }
  214. },
  215. isRW1: false, // 第一班
  216. isRW2: false, // 第二班
  217. isRW3: false, // 第三班
  218. isRW4: false, // 第四班
  219. getdataListParm3: {
  220. name: 'getSysoptEnable1',
  221. page: 1,
  222. offset: 1,
  223. pagecount: 1,
  224. returntype: 'Map',
  225. parammaps: {
  226. pastureid: Cookies.get('pastureid'),
  227. inforname: 'times'
  228. }
  229. },
  230. RWLength: '' // 班次长度
  231. },
  232. selectList: [],
  233. focusWRow: {}, // 一班重量得到焦点暂存
  234. focusWRow2: {}, // 2班重量得到焦点暂存
  235. focusWRow3: {}, // 3班重量得到焦点暂存
  236. focusWRow4: {}, // 4班重量得到焦点暂存
  237. requestParam: {},
  238. isokDisable: false,
  239. rowStyle: { maxHeight: 50 + 'px', height: 35 + 'px' },
  240. cellStyle: { padding: 0 + 'px' }
  241. }
  242. },
  243. watch: {
  244. show: {
  245. immediate: true,
  246. handler(show) {
  247. this.visible = show
  248. }
  249. },
  250. parentDate: {
  251. immediate: true,
  252. handler(newVal, oldVal) {
  253. this.date = newVal
  254. }
  255. }
  256. },
  257. created() {
  258. this.getIsDisplay()
  259. this.getDownList()
  260. },
  261. methods: {
  262. getDownList() {
  263. GetDataByNames(this.requestParams).then(response => {
  264. this.recipeTemplateList = response.data.getFTSWList.list
  265. this.feedingFormulaList = response.data.getFTBLList.list
  266. this.livestockTypeList = response.data.getCowclassListEnable.list
  267. })
  268. },
  269. getIsDisplay() {
  270. GetDataByName(this.table.getdataListParm2).then(response => {
  271. console.log(response.data.list[0].inforvalue)
  272. if (response.data.list !== null) {
  273. if (response.data.list[0].inforvalue == 0) {
  274. this.table.isPtsfname = false
  275. } else {
  276. this.table.isPtsfname = true
  277. }
  278. }
  279. })
  280. GetDataByName(this.table.getdataListParm3).then(response => {
  281. console.log(response.data.list[0].inforvalue)
  282. if (response.data.list !== null) {
  283. this.table.RWLength = response.data.list[0].inforvalue
  284. if (response.data.list[0].inforvalue == 1) {
  285. this.table.isRW1 = true
  286. this.table.isRW2 = false
  287. this.table.isRW3 = false
  288. this.table.isRW4 = false
  289. } else if (response.data.list[0].inforvalue == 2) {
  290. this.table.isRW1 = true
  291. this.table.isRW2 = true
  292. this.table.isRW3 = false
  293. this.table.isRW4 = false
  294. } else if (response.data.list[0].inforvalue == 3) {
  295. this.table.isRW1 = true
  296. this.table.isRW2 = true
  297. this.table.isRW3 = true
  298. this.table.isRW4 = false
  299. } else if (response.data.list[0].inforvalue == 4) {
  300. this.table.isRW1 = true
  301. this.table.isRW2 = true
  302. this.table.isRW3 = true
  303. this.table.isRW4 = true
  304. }
  305. } else {
  306. this.table.isRW1 = false
  307. this.table.isRW2 = false
  308. this.table.isRW3 = false
  309. this.table.isRW4 = false
  310. }
  311. })
  312. this.getList()
  313. },
  314. getList() {
  315. this.table.listLoading = true
  316. GetDataByName(this.table.getdataListParm).then(response => {
  317. console.log('table数据', response.data.list)
  318. if (response.data.list !== null) {
  319. for (let i = 0; i < response.data.list.length; i++) {
  320. this.$set(response.data.list[i], 'Edit', false) // 编辑
  321. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  322. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  323. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  324. if (response.data.list[i].ftid == undefined || response.data.list[i].ftname == '') {
  325. this.$set(response.data.list[i], 'ftid', '')
  326. this.$set(response.data.list[i], 'ftname', '')
  327. }
  328. if (response.data.list[i].ptsfid == undefined || response.data.list[i].ptsfname == '') {
  329. this.$set(response.data.list[i], 'ptsfid', '')
  330. this.$set(response.data.list[i], 'ptsfname', '')
  331. }
  332. if (response.data.list[i].ccount == undefined) {
  333. this.$set(response.data.list[i], 'ccount', '')
  334. }
  335. if (response.data.list[i].softccount == undefined) {
  336. this.$set(response.data.list[i], 'softccount', '')
  337. }
  338. if (response.data.list[i].ratio == undefined) {
  339. this.$set(response.data.list[i], 'ratio', 100)
  340. }
  341. if (response.data.list[i].ccountratio == undefined) {
  342. this.$set(response.data.list[i], 'ccountratio', '')
  343. }
  344. if (response.data.list[i].r1 == undefined) {
  345. this.$set(response.data.list[i], 'r1', '')
  346. }
  347. if (response.data.list[i].r2 == undefined) {
  348. this.$set(response.data.list[i], 'r2', '')
  349. }
  350. if (response.data.list[i].r3 == undefined) {
  351. this.$set(response.data.list[i], 'r3', '')
  352. }
  353. if (response.data.list[i].r4 == undefined) {
  354. this.$set(response.data.list[i], 'r4', '')
  355. }
  356. if (response.data.list[i].w1 == undefined) {
  357. this.$set(response.data.list[i], 'w1', '')
  358. }
  359. if (response.data.list[i].w2 == undefined) {
  360. this.$set(response.data.list[i], 'w2', '')
  361. }
  362. if (response.data.list[i].w3 == undefined) {
  363. this.$set(response.data.list[i], 'w3', '')
  364. }
  365. if (response.data.list[i].w4 == undefined) {
  366. this.$set(response.data.list[i], 'w4', '')
  367. }
  368. if (response.data.list[i].supplyweight == undefined) {
  369. this.$set(response.data.list[i], 'supplyweight', '')
  370. }
  371. if (response.data.list[i].feedweight == undefined) {
  372. this.$set(response.data.list[i], 'feedweight', '')
  373. }
  374. if (response.data.list[i].Bfweight == undefined) {
  375. this.$set(response.data.list[i], 'Bfweight', '')
  376. }
  377. if (response.data.list[i].Sfweight == undefined) {
  378. this.$set(response.data.list[i], 'Sfweight', '')
  379. }
  380. if (response.data.list[i].isOneWeight == undefined) {
  381. this.$set(response.data.list[i], 'isOneWeight', false)
  382. }
  383. if (response.data.list[i].isTwoWeight == undefined) {
  384. this.$set(response.data.list[i], 'isTwoWeight', false)
  385. }
  386. if (response.data.list[i].isThreeWeight == undefined) {
  387. this.$set(response.data.list[i], 'isThreeWeight', false)
  388. }
  389. if (response.data.list[i].isFourWeight == undefined) {
  390. this.$set(response.data.list[i], 'isFourWeight', false)
  391. }
  392. if (response.data.list[i].timesopt !== undefined) {
  393. var timesoptArr = response.data.list[i].timesopt.split(',')
  394. for (let j = 0; j < timesoptArr.length; j++) {
  395. response.data.list[i]['r' + timesoptArr[j].split(':')[0]] = timesoptArr[j].split(':')[1]
  396. response.data.list[i]['w' + timesoptArr[j].split(':')[0]] = timesoptArr[j].split(':')[2]
  397. }
  398. }
  399. }
  400. // console.log(response.data.list, sumr)
  401. for (let i = 0; i < response.data.list.length; i++) {
  402. if (response.data.list[i].r1 == '') {
  403. response.data.list[i].r1 = 0
  404. }
  405. if (response.data.list[i].r2 == '') {
  406. response.data.list[i].r2 = 0
  407. }
  408. if (response.data.list[i].r3 == '') {
  409. response.data.list[i].r3 = 0
  410. }
  411. if (response.data.list[i].r4 == '') {
  412. response.data.list[i].r4 = 0
  413. }
  414. this.$set(response.data.list[i], 'sumr', parseFloat(response.data.list[i].r1) + parseFloat(response.data.list[i].r2) + parseFloat(response.data.list[i].r3) + parseFloat(response.data.list[i].r4))
  415. response.data.list[i].sumr = formatNum(response.data.list[i].sumr, 2)
  416. }
  417. this.table.list = response.data.list
  418. console.log(this.table.list, 'this.table.list')
  419. this.table.pageNum = response.data.pageNum
  420. this.table.pageSize = response.data.pageSize
  421. this.table.total = response.data.total
  422. } else {
  423. this.table.list = []
  424. }
  425. setTimeout(() => {
  426. this.table.listLoading = false
  427. }, 100)
  428. })
  429. },
  430. renderHeader(h, { column, $index }) { // h即为cerateElement的简写,具体可看vue官方文档
  431. // console.log(column)
  432. return h(
  433. 'div',
  434. [
  435. h('span', column.label),
  436. h('i', {
  437. class: 'el-icon-unlock',
  438. ref: 'el-icon-unlock',
  439. style: 'margin-left:5px;'
  440. })
  441. ]
  442. )
  443. },
  444. headerClick(column, event) {
  445. console.log(column, event)
  446. if (column.label == '第一班重量') {
  447. for (let i = 0; i < this.table.list.length; i++) {
  448. if (this.table.list[i].Edit == true) {
  449. if (event.target.outerHTML == '<i class="el-icon-unlock" style="margin-left: 5px;"></i>') {
  450. event.target.className = 'el-icon-lock'
  451. this.$set(this.table.list[i], 'isOneWeight', true) // 锁住不可编辑
  452. } else if (event.target.outerHTML == '<i class="el-icon-lock" style="margin-left: 5px;"></i>') {
  453. event.target.className = 'el-icon-unlock'
  454. this.$set(this.table.list[i], 'isOneWeight', false) // 解锁可编辑
  455. }
  456. }
  457. }
  458. } else if (column.label == '第二班重量') {
  459. for (let i = 0; i < this.table.list.length; i++) {
  460. if (this.table.list[i].Edit == true) {
  461. if (event.target.outerHTML == '<i class="el-icon-unlock" style="margin-left: 5px;"></i>') {
  462. event.target.className = 'el-icon-lock'
  463. this.$set(this.table.list[i], 'isTwoWeight', true) // 锁住不可编辑
  464. } else if (event.target.outerHTML == '<i class="el-icon-lock" style="margin-left: 5px;"></i>') {
  465. event.target.className = 'el-icon-unlock'
  466. this.$set(this.table.list[i], 'isTwoWeight', false) // 解锁可编辑
  467. }
  468. }
  469. }
  470. } else if (column.label == '第三班重量') {
  471. for (let i = 0; i < this.table.list.length; i++) {
  472. if (this.table.list[i].Edit == true) {
  473. if (event.target.outerHTML == '<i class="el-icon-unlock" style="margin-left: 5px;"></i>') {
  474. event.target.className = 'el-icon-lock'
  475. this.$set(this.table.list[i], 'isThreeWeight', true) // 锁住不可编辑
  476. } else if (event.target.outerHTML == '<i class="el-icon-lock" style="margin-left: 5px;"></i>') {
  477. event.target.className = 'el-icon-unlock'
  478. this.$set(this.table.list[i], 'isThreeWeight', false) // 解锁可编辑
  479. }
  480. }
  481. }
  482. } else if (column.label == '第四班重量') {
  483. for (let i = 0; i < this.table.list.length; i++) {
  484. if (this.table.list[i].Edit == true) {
  485. if (event.target.outerHTML == '<i class="el-icon-unlock" style="margin-left: 5px;"></i>') {
  486. event.target.className = 'el-icon-lock'
  487. this.$set(this.table.list[i], 'isFourWeight', true) // 锁住不可编辑
  488. } else if (event.target.outerHTML == '<i class="el-icon-lock" style="margin-left: 5px;"></i>') {
  489. event.target.className = 'el-icon-unlock'
  490. this.$set(this.table.list[i], 'isFourWeight', false) // 解锁可编辑
  491. }
  492. }
  493. }
  494. }
  495. },
  496. // 配方模板
  497. changeRecipeTemplate(item, row) {
  498. console.log(row.supplyweight, 'row.supplyweight')
  499. row.ftname = this.recipeTemplateList.find(obj => obj.id == item).tname
  500. row.Sfweight = this.recipeTemplateList.find(obj => obj.id == item).Sfweight// Sfweight
  501. row.SfweightLock = this.recipeTemplateList.find(obj => obj.id == item).SfweightLock// SfweightLock
  502. // 补料重量supplyweight
  503. // 配方重量ftweight
  504. // 系数头数ccountratio
  505. // 投喂量feedweight
  506. // 实际牛头数ccount
  507. // 投喂量 = 配方重量 + 补料重量
  508. // 配方重量 = Sfweight * 系数头数 + SfweightLock * 实际牛头数ccount
  509. console.log(row.Sfweight, 'row.Sfweight')
  510. console.log(row.ccountratio, '系数头数')
  511. console.log(row.SfweightLock, 'SfweightLock')
  512. console.log(row.ccount, '实际牛头数')
  513. if (row.Sfweight !== '' && row.ccount !== '') {
  514. this.$set(row, 'ftweight', formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2))
  515. } else {
  516. row.ftweight = ''
  517. }
  518. // console.log(row.ftweight, 'row.ftweight')
  519. // console.log(row.supplyweight, 'row.supplyweight')
  520. // console.log(this.table.isPtsfname, 'isPtsfname')
  521. if (this.table.isPtsfname == false) {
  522. row.feedweight = formatNum(parseFloat(row.ftweight), 2)
  523. } else {
  524. if (row.supplyweight == 'NaN') {
  525. row.supplyweight = 0
  526. }
  527. console.log(row.supplyweight)
  528. if (row.supplyweight !== '' && row.ftweight !== '') {
  529. row.feedweight = formatNum(parseFloat(row.supplyweight) + parseFloat(row.ftweight), 2)
  530. } else if (row.supplyweight == '' && row.ftweight !== '') {
  531. row.feedweight = formatNum(parseFloat(row.ftweight), 2)
  532. } else if (row.supplyweight !== '' && row.ftweight !== '') {
  533. row.feedweight = formatNum(parseFloat(row.supplyweight), 2)
  534. }
  535. if (row.ccountratio !== '' && row.ftweight !== '') {
  536. row.ftweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  537. }
  538. if (row.Sfweight !== '' && row.ccount !== '') {
  539. this.$set(row, 'ftweight', formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2))
  540. } else {
  541. row.ftweight = ''
  542. }
  543. }
  544. console.log(row.supplyweight)
  545. if (row.supplyweight == 'NaN') { row.supplyweight = 0 }
  546. if (row.r1 !== '') { this.$set(row, 'w1', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r1) / 100), 2)) }
  547. if (row.r2 !== '') { this.$set(row, 'w2', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r2) / 100), 2)) }
  548. if (row.r3 !== '') { this.$set(row, 'w3', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r3) / 100), 2)) }
  549. if (row.r4 !== '') { this.$set(row, 'w4', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r4) / 100), 2)) }
  550. },
  551. // 补料配方
  552. changeFeedingFormula(item, row) {
  553. console.log(item, '=========')
  554. // 补料重量supplyweight
  555. // 配方重量ftweight
  556. // 系数头数ccountratio
  557. // 投喂量feedweight
  558. // 实际牛头数ccount
  559. // 投喂量 = 配方重量 + 补料重量
  560. if (item !== '') {
  561. console.log(456)
  562. row.ptsfname = this.feedingFormulaList.find(obj => obj.id == item).tname
  563. row.BLweight = this.feedingFormulaList.find(obj => obj.id == item).Sfweight
  564. row.BLSfweightLock = this.feedingFormulaList.find(obj => obj.id == item).SfweightLock
  565. } else {
  566. row.ptsfname = ''
  567. row.BLweight = 0
  568. row.BLSfweightLock = 0
  569. }
  570. // 配方重量 = 系数头数 * Sfweight
  571. // if (row.ccountratio !== '' && row.ftweight !== '') {
  572. // row.ftweight = parseFloat(row.Sfweight) * parseFloat(row.ccountratio)
  573. // }
  574. // 补料重量 = 系数头数 * BLweight
  575. // console.log(row.ccountratio)
  576. // console.log(row.ccount)
  577. // console.log(row.BLweight)
  578. // console.log(row.BLSfweightLock)
  579. if (row.ccountratio !== '' && row.ccount !== '' && row.ccount.BLweight !== '' && row.BLSfweightLock !== '') {
  580. this.$set(row, 'supplyweight', formatNum(parseFloat(row.BLweight) * parseFloat(row.ccountratio) + parseFloat(row.BLSfweightLock) * parseFloat(row.ccount), 2))
  581. } else {
  582. row.supplyweight = ''
  583. }
  584. if (this.table.isPtsfname == false) {
  585. row.feedweight = parseFloat(row.ftweight)
  586. } else {
  587. if (row.supplyweight !== '' && row.ftweight !== '') {
  588. row.feedweight = formatNum(parseFloat(row.supplyweight) + parseFloat(row.ftweight), 2)
  589. } else if (row.supplyweight == '' && row.ftweight !== '') {
  590. row.feedweight = formatNum(parseFloat(row.ftweight), 2)
  591. } else if (row.supplyweight !== '' && row.ftweight == '') {
  592. row.feedweight = formatNum(parseFloat(row.supplyweight), 2)
  593. }
  594. // if (row.ccountratio !== '' && row.ftweight !== '') {
  595. // row.ftweight = parseFloat(row.Sfweight) * parseFloat(row.ccountratio)
  596. // }
  597. // if (row.ccountratio !== '' && row.BLweight !== '') {
  598. // row.supplyweight = parseFloat(row.BLweight) * parseFloat(row.ccountratio)
  599. // }
  600. }
  601. if (row.r1 !== '') { this.$set(row, 'w1', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r1) / 100), 2)) }
  602. if (row.r2 !== '') { this.$set(row, 'w2', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r2) / 100), 2)) }
  603. if (row.r3 !== '') { this.$set(row, 'w3', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r3) / 100), 2)) }
  604. if (row.r4 !== '') { this.$set(row, 'w4', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r4) / 100), 2)) }
  605. },
  606. // 实际牛头数失去焦点计算
  607. // ccount实际牛头数
  608. // ratio系数
  609. // ccountratio系数牛头数
  610. blurCcount(row) { // 实际牛头数
  611. console.log(row)
  612. if (row.ftid !== '-1' && row.ftid !== '') {
  613. console.log(this.recipeTemplateList.find(obj => obj.id == row.ftid).Sfweight)
  614. row.Sfweight = this.recipeTemplateList.find(obj => obj.id == row.ftid).Sfweight
  615. row.SfweightLock = this.recipeTemplateList.find(obj => obj.id == row.ftid).SfweightLock
  616. }
  617. if (row.ptsfid !== '-1' && row.ptsfid !== '' && this.table.isPtsfname == true) {
  618. // row.ptsfid = parseInt(row.ptsfid)
  619. row.BLweight = formatNum(parseFloat(this.feedingFormulaList.find(obj => obj.id == row.ptsfid).Sfweight), 2)
  620. row.BLweightLock = formatNum(parseFloat(this.feedingFormulaList.find(obj => obj.id == row.ptsfid).SfweightLock), 2)
  621. }
  622. if (row.ptsfid == '') {
  623. row.BLweight = 0
  624. row.BLweightLock = 0
  625. }
  626. if (row.Sfweight !== '' && row.ccount !== '') {
  627. // console.log(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount))
  628. row.ftweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  629. }
  630. // 系数牛头数 = 实际牛头数 * 系数/100
  631. if (row.ccount !== '' && row.ratio !== '') {
  632. row.ccountratio = formatNum(parseFloat(row.ccount) * parseFloat(row.ratio) / 100, 2)
  633. } else if (row.ratio !== '' && row.ccountratio !== '') {
  634. row.ccount = formatNum(parseFloat(row.ccountratio) * 100 / parseFloat(row.ratio) / 100, 2)
  635. } else if (row.ccount !== '' || row.ratio !== '') {
  636. row.ccountratio = ''
  637. }
  638. // 补料重量
  639. console.log(row.ccountratio, row.BLweight)
  640. if (row.BLweight == 'undefined') {
  641. this.$set(row, 'BLweight', '')
  642. }
  643. console.log('BLweight', row.BLweight)
  644. console.log('ccountratio', row.ccountratio)
  645. console.log('BLweightLock', row.BLweightLock)
  646. console.log('ccount', row.ccount)
  647. if (row.ccountratio !== '' && row.BLweight !== '') {
  648. row.supplyweight = formatNum(parseFloat(row.BLweight) * parseFloat(row.ccountratio) + parseFloat(row.BLweightLock) * parseFloat(row.ccount), 2)
  649. } else if (row.ccountratio !== '' && row.BLweight == '') {
  650. row.supplyweight = ''
  651. row.feedweight = ''
  652. } else if (row.ccountratio == '' && row.BLweight !== '') {
  653. row.supplyweight = ''
  654. row.feedweight = ''
  655. }
  656. // 配方重量
  657. if (row.ccountratio !== '' && row.Sfweight !== '') {
  658. row.ftweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  659. } else if (row.ccountratio !== '' && row.Sfweight == '') {
  660. row.ftweight = ''
  661. row.feedweight = ''
  662. } else if (row.ccountratio == '' && row.Sfweight !== '') {
  663. row.ftweight = ''
  664. row.feedweight = ''
  665. }
  666. if (this.table.isPtsfname == false) {
  667. row.feedweight = parseFloat(row.ftweight)
  668. } else {
  669. if (row.supplyweight !== '' && row.ftweight !== '') {
  670. row.feedweight = formatNum(parseFloat(row.supplyweight) + parseFloat(row.ftweight), 2)
  671. } else if (row.supplyweight !== '' && row.ftweight == '') {
  672. row.feedweight = formatNum(parseFloat(row.supplyweight), 2)
  673. } else if (row.supplyweight == '' && row.ftweight !== '') {
  674. row.feedweight = formatNum(parseFloat(row.ftweight), 2)
  675. }
  676. // 配方重量 = 系数头数 * Sfweight
  677. if (row.ccountratio !== '' && row.ftweight !== '') {
  678. row.ftweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  679. }
  680. // 补料重量 = 系数头数 * BLweight
  681. if (row.ccountratio !== '' && row.BLweight !== '') {
  682. row.supplyweight = formatNum(parseFloat(row.BLweight) * parseFloat(row.ccountratio) + parseFloat(row.BLweightLock) * parseFloat(row.ccount), 2)
  683. }
  684. }
  685. if (row.r1 !== '') { this.$set(row, 'w1', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r1) / 100), 2)) }
  686. if (row.r2 !== '') { this.$set(row, 'w2', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r2) / 100), 2)) }
  687. if (row.r3 !== '') { this.$set(row, 'w3', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r3) / 100), 2)) }
  688. if (row.r4 !== '') { this.$set(row, 'w4', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r4) / 100), 2)) }
  689. },
  690. blurRatio(row) {
  691. console.log(row, '--------------')
  692. if (row.ftid !== '-1' && row.ftid !== '') {
  693. row.Sfweight = this.recipeTemplateList.find(obj => obj.id == row.ftid).Sfweight
  694. row.SfweightLock = this.recipeTemplateList.find(obj => obj.id == row.ftid).SfweightLock
  695. }
  696. if (row.ptsfid !== '-1' && row.ptsfid !== '' && this.table.isPtsfname == true) {
  697. // row.ptsfid = parseInt(row.ptsfid)
  698. row.BLweight = formatNum(parseFloat(this.feedingFormulaList.find(obj => obj.id == row.ptsfid).Sfweight), 2)
  699. row.BLweightLock = formatNum(parseFloat(this.feedingFormulaList.find(obj => obj.id == row.ptsfid).SfweightLock), 2)
  700. }
  701. if (row.ptsfid == '') {
  702. row.BLweight = 0
  703. row.BLweightLock = 0
  704. }
  705. // 系数
  706. if (row.ccount !== '' && row.ratio !== '' && row.ccountratio !== '') {
  707. row.ccountratio = formatNum(parseFloat(row.ccount) * parseFloat(row.ratio) / 100, 2)
  708. } else if (row.ccount !== '' && row.ccountratio !== '') {
  709. row.ratio = formatNum(parseFloat(row.ccountratio) * 100 / parseFloat(row.ccount), 2)
  710. } else if (row.ccount !== '' || row.ccountratio !== '') {
  711. row.ratio = ''
  712. }
  713. // 补料重量
  714. if (row.ccountratio !== '' && row.BLweight !== '') {
  715. row.supplyweight = formatNum(parseFloat(row.BLweight) * parseFloat(row.ccountratio) + parseFloat(row.BLweightLock) * parseFloat(row.ccount), 2)
  716. } else if (row.ccountratio !== '' && row.BLweight == '' || row.ccountratio == '' && row.BLweight !== '') {
  717. row.supplyweight = ''
  718. row.feedweight = ''
  719. }
  720. // 配方重量
  721. if (row.ccountratio !== '' && row.Sfweight !== '') {
  722. row.ftweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  723. } else if (row.ccountratio !== '' && row.Sfweight == '' || row.ccountratio == '' && row.Sfweight !== '') {
  724. row.ftweight = ''
  725. row.feedweight = ''
  726. }
  727. // 投喂量
  728. if (row.supplyweight !== '' && row.ftweight !== '') {
  729. row.feedweight = formatNum(parseFloat(row.BLweight) * parseFloat(row.ccountratio) + parseFloat(row.BLweightLock) * parseFloat(row.ccount), 2)
  730. } else if (row.supplyweight == '' && row.ftweight !== '') {
  731. row.feedweight = formatNum(parseFloat(row.ftweight), 2)
  732. } else if (row.supplyweight !== '' && row.ftweight == '') {
  733. row.feedweight = formatNum(parseFloat(row.supplyweight), 2)
  734. }
  735. console.log(row.supplyweight, '补料重量')
  736. console.log(row.ftweight, '配方重量')
  737. if (this.table.isPtsfname == false) {
  738. row.feedweight = formatNum(parseFloat(row.ftweight), 2)
  739. } else {
  740. // 投喂量
  741. if (row.supplyweight !== '' && row.ftweight !== '') {
  742. row.feedweight = formatNum(parseFloat(row.supplyweight) + parseFloat(row.ftweight), 2)
  743. } else if (row.supplyweight == '' && row.ftweight !== '') {
  744. row.feedweight = formatNum(parseFloat(row.ftweight), 2)
  745. } else if (row.supplyweight !== '' && row.ftweight == '') {
  746. row.feedweight = formatNum(parseFloat(row.supplyweight), 2)
  747. }
  748. // 补料重量
  749. if (row.ccountratio !== '' && row.BLweight !== '') {
  750. row.supplyweight = formatNum(parseFloat(row.BLweight) * parseFloat(row.ccountratio) + parseFloat(row.BLweightLock) * parseFloat(row.ccount), 2)
  751. } else if (row.ccountratio !== '' && row.BLweight == '') {
  752. row.supplyweight = ''
  753. row.feedweight = ''
  754. } else if (row.ccountratio == '' && row.BLweight !== '') {
  755. row.supplyweight = ''
  756. row.feedweight = ''
  757. }
  758. // 配方重量
  759. if (row.ccountratio !== '' && row.Sfweight !== '') {
  760. row.ftweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  761. } else if (row.ccountratio !== '' && row.Sfweight == '') {
  762. row.ftweight = ''
  763. row.feedweight = ''
  764. } else if (row.ccountratio == '' && row.Sfweight !== '') {
  765. row.ftweight = ''
  766. row.feedweight = ''
  767. }
  768. }
  769. if (row.r1 !== '') { this.$set(row, 'w1', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r1) / 100), 2)) }
  770. if (row.r2 !== '') { this.$set(row, 'w2', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r2) / 100), 2)) }
  771. if (row.r3 !== '') { this.$set(row, 'w3', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r3) / 100), 2)) }
  772. if (row.r4 !== '') { this.$set(row, 'w4', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r4) / 100), 2)) }
  773. },
  774. blurCcountratio(row) {
  775. if (row.ftid !== '-1' && row.ftid !== '') {
  776. row.Sfweight = this.recipeTemplateList.find(obj => obj.id == row.ftid).Sfweight
  777. row.SfweightLock = this.recipeTemplateList.find(obj => obj.id == row.ftid).SfweightLock
  778. }
  779. if (row.ptsfid !== '-1' && row.ptsfid !== '' && this.table.isPtsfname == true) {
  780. // row.ptsfid = parseInt(row.ptsfid)
  781. row.BLweight = formatNum(parseFloat(this.feedingFormulaList.find(obj => obj.id == row.ptsfid).Sfweight), 2)
  782. row.BLweightLock = formatNum(parseFloat(this.feedingFormulaList.find(obj => obj.id == row.ptsfid).SfweightLock), 2)
  783. }
  784. if (row.ptsfid == '') {
  785. row.BLweight = 0
  786. row.BLweightLock = 0
  787. }
  788. if (row.ptsfid == '') {
  789. row.BLweight = 0
  790. row.BLweightLock = 0
  791. }
  792. // 系数头数
  793. if (row.ccountratio !== '' && row.ccount !== '' && row.ratio !== '') {
  794. row.ratio = formatNum(parseFloat(row.ccountratio) * 100 / parseFloat(row.ccount), 2)
  795. } else if (row.ccount !== '' && row.ratio !== '') {
  796. row.ccountratio = formatNum(parseFloat(row.ccount) * parseFloat(row.ratio) / 100, 2)
  797. } else if (row.ccountratio !== '' && row.ccount !== '') {
  798. row.ratio = formatNum(parseFloat(row.ccountratio) * 100 / parseFloat(row.ccount), 2)
  799. } else if (row.ccountratio !== '' && row.ratio !== '') {
  800. row.ccount = formatNum(parseFloat(row.ccountratio) * 100 / parseFloat(row.ratio) / 100, 2)
  801. }
  802. // 补料重量
  803. if (row.ccountratio !== '' && row.BLweight !== '') {
  804. row.supplyweight = formatNum(parseFloat(row.BLweight) * parseFloat(row.ccountratio) + parseFloat(row.BLweightLock) * parseFloat(row.ccount), 2)
  805. } else if (row.ccountratio !== '' && row.BLweight == '') {
  806. row.supplyweight = ''
  807. row.feedweight = ''
  808. } else if (row.ccountratio == '' && row.BLweight !== '') {
  809. row.supplyweight = ''
  810. row.feedweight = ''
  811. }
  812. // 配方重量
  813. if (row.ccountratio !== '' && row.Sfweight !== '') {
  814. row.ftweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  815. } else if (row.ccountratio !== '' && row.Sfweight == '') {
  816. row.ftweight = ''
  817. row.feedweight = ''
  818. } else if (row.ccountratio == '' && row.Sfweight !== '') {
  819. row.ftweight = ''
  820. row.feedweight = ''
  821. }
  822. // 投喂量
  823. if (row.supplyweight !== '' && row.ftweight !== '') {
  824. row.feedweight = formatNum(parseFloat(row.supplyweight) + parseFloat(row.ftweight), 2)
  825. } else if (row.supplyweight == '' && row.ftweight !== '') {
  826. row.feedweight = formatNum(parseFloat(row.ftweight), 2)
  827. } else if (row.supplyweight !== '' && row.ftweight == '') {
  828. row.feedweight = formatNum(parseFloat(row.supplyweight), 2)
  829. }
  830. if (this.table.isPtsfname == false) {
  831. console.log(row)
  832. row.feedweight = formatNum(parseFloat(row.ftweight), 2)
  833. } else {
  834. // 投喂量
  835. if (row.supplyweight !== '' && row.ftweight !== '') {
  836. row.feedweight = formatNum(parseFloat(row.supplyweight) + parseFloat(row.ftweight), 2)
  837. } else if (row.supplyweight == '' && row.ftweight !== '') {
  838. row.feedweight = formatNum(parseFloat(row.ftweight), 2)
  839. } else if (row.supplyweight !== '' && row.ftweight == '') {
  840. row.feedweight = formatNum(parseFloat(row.supplyweight), 2)
  841. }
  842. // 补料重量
  843. if (row.ccountratio !== '' && row.BLweight !== '') {
  844. row.supplyweight = formatNum(parseFloat(row.BLweight) * parseFloat(row.ccountratio) + parseFloat(row.BLweightLock) * parseFloat(row.ccount), 2)
  845. } else if (row.ccountratio !== '' && row.BLweight == '') {
  846. row.supplyweight = ''
  847. row.feedweight = ''
  848. } else if (row.ccountratio == '' && row.BLweight !== '') {
  849. row.supplyweight = ''
  850. row.feedweight = ''
  851. }
  852. // 配方重量
  853. if (row.ccountratio !== '' && row.Sfweight !== '') {
  854. row.ftweight = formatNum(parseFloat(row.Sfweight) * parseFloat(row.ccountratio) + parseFloat(row.SfweightLock) * parseFloat(row.ccount), 2)
  855. } else if (row.ccountratio !== '' && row.Sfweight == '') {
  856. row.ftweight = ''
  857. row.feedweight = ''
  858. } else if (row.ccountratio == '' && row.Sfweight !== '') {
  859. row.ftweight = ''
  860. row.feedweight = ''
  861. }
  862. }
  863. if (row.r1 !== '') { this.$set(row, 'w1', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r1) / 100), 2)) }
  864. if (row.r2 !== '') { this.$set(row, 'w2', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r2) / 100), 2)) }
  865. if (row.r3 !== '') { this.$set(row, 'w3', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r3) / 100), 2)) }
  866. if (row.r4 !== '') { this.$set(row, 'w4', formatNum(parseFloat(row.feedweight) * (parseFloat(row.r4) / 100), 2)) }
  867. },
  868. // 总比例
  869. blurR(row) {
  870. if (row.r1 == '') { row.r1 = 0 }
  871. if (row.r2 == '') { row.r2 = 0 }
  872. if (row.r3 == '') { row.r3 = 0 }
  873. if (row.r4 == '') { row.r4 = 0 }
  874. if (row.r1 !== '') {
  875. row.w1 = formatNum(parseFloat(row.feedweight) * parseFloat(row.r1) / 100, 2)
  876. }
  877. if (row.r2 !== '') {
  878. row.w2 = formatNum(parseFloat(row.feedweight) * parseFloat(row.r2) / 100, 2)
  879. }
  880. if (row.r3 !== '') {
  881. row.w3 = formatNum(parseFloat(row.feedweight) * parseFloat(row.r3) / 100, 2)
  882. }
  883. if (row.r4 !== '') {
  884. row.w4 = formatNum(parseFloat(row.feedweight) * parseFloat(row.r4) / 100, 2)
  885. }
  886. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  887. },
  888. // 一班重量得到焦点
  889. focusW(row) {
  890. console.log(row)
  891. this.focusWRow = Object.assign({}, row)
  892. },
  893. // 1班重量得到焦点
  894. focusW2(row) {
  895. this.focusWRow2 = Object.assign({}, row)
  896. },
  897. // 3班重量得到焦点
  898. focusW3(row) {
  899. this.focusWRow3 = Object.assign({}, row)
  900. },
  901. // 4班重量得到焦点
  902. focusW4(row) {
  903. this.focusWRow4 = Object.assign({}, row)
  904. },
  905. // 一班重量
  906. blurW(row) {
  907. if (row.w1 == '') {
  908. row.w1 = 0
  909. }
  910. if (row.w2 == '') {
  911. row.w2 = 0
  912. }
  913. if (row.w3 == '') {
  914. row.w3 = 0
  915. }
  916. if (row.w4 == '') {
  917. row.w4 = 0
  918. }
  919. if (row.r1 == '') {
  920. row.r1 = 0
  921. }
  922. if (row.r2 == '') {
  923. row.r2 = 0
  924. }
  925. if (row.r3 == '') {
  926. row.r3 = 0
  927. }
  928. if (row.r4 == '') {
  929. row.r4 = 0
  930. }
  931. // row.ftweight = parseFloat(row.w1) + parseFloat(row.w2) + parseFloat(row.w3) + parseFloat(row.w4)
  932. console.log(row, '=======投喂量feedweight')
  933. // isOneWeight,isTwoWeight,isThreeWeight,isFourWeight
  934. if (this.table.RWLength == 4) {
  935. // 2班3班4班都锁定
  936. if (row.isTwoWeight == true && row.isThreeWeight == true && row.isFourWeight == true) {
  937. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  938. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  939. }
  940. // 2班3班锁定4班未锁定
  941. if (row.isTwoWeight == true && row.isThreeWeight == true && row.isFourWeight == false) {
  942. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  943. row.w4 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w2) - parseFloat(row.w3), 2)
  944. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  945. if (row.w4 <= 0) {
  946. row.w4 = 0
  947. row.r4 = 0
  948. }
  949. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  950. }
  951. // 2班4班锁定3班未锁定
  952. if (row.isTwoWeight == true && row.isFourWeight == true && row.isThreeWeight == false) {
  953. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  954. row.w3 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w2) - parseFloat(row.w4), 2)
  955. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  956. if (row.w3 <= 0) {
  957. row.w3 = 0
  958. row.r3 = 0
  959. }
  960. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  961. }
  962. // 3班4班锁定2班未锁定
  963. if (row.isTwoWeight == false && row.isThreeWeight == true && row.isFourWeight == true) {
  964. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  965. row.w2 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w3) - parseFloat(row.w4), 2)
  966. row.r2 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  967. if (row.w2 <= 0) {
  968. row.w2 = 0
  969. row.r2 = 0
  970. }
  971. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  972. }
  973. // 2班锁定,3班4班未锁
  974. if (row.isTwoWeight == true && row.isThreeWeight == false && row.isFourWeight == false) {
  975. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  976. row.w3 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w2)) * parseFloat(row.r3) / (parseFloat(this.focusWRow.r3) + parseFloat(this.focusWRow.r4)), 2)
  977. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100)
  978. row.w4 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w2)) * parseFloat(row.r4) / (parseFloat(this.focusWRow.r3) + parseFloat(row.r4)), 2)
  979. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100)
  980. if (row.w3 <= 0) {
  981. row.w3 = 0
  982. row.r3 = 0
  983. }
  984. if (row.w4 <= 0) {
  985. row.w4 = 0
  986. row.r4 = 0
  987. }
  988. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  989. }
  990. // 3班锁定,2班4班未锁
  991. if (row.isTwoWeight == false && row.isThreeWeight == true && row.isFourWeight == false) {
  992. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  993. row.w2 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w3)) * parseFloat(row.r2) / (parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r4)), 2)
  994. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  995. row.w4 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w3)) * parseFloat(row.r4) / (parseFloat(this.focusWRow.r2) + parseFloat(row.r4)), 2)
  996. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  997. if (row.w2 <= 0) {
  998. row.w2 = 0
  999. row.r2 = 0
  1000. }
  1001. if (row.w4 <= 0) {
  1002. row.w4 = 0
  1003. row.r4 = 0
  1004. }
  1005. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1006. }
  1007. // 4班锁定,2班3班未锁
  1008. if (row.isTwoWeight == false && row.isThreeWeight == false && row.isFourWeight == true) {
  1009. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1010. row.w2 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w4)) * parseFloat(row.r2) / (parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r3)), 2)
  1011. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1012. row.w3 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w4)) * parseFloat(row.r3) / (parseFloat(this.focusWRow.r2) + parseFloat(row.r3)), 2)
  1013. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1014. if (row.w2 <= 0) {
  1015. row.w2 = 0
  1016. row.r2 = 0
  1017. }
  1018. if (row.w3 <= 0) {
  1019. row.w3 = 0
  1020. row.r3 = 0
  1021. }
  1022. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1023. }
  1024. // 2班3班4班未锁
  1025. if (row.isTwoWeight == false && row.isThreeWeight == false && row.isFourWeight == false) {
  1026. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1027. row.w2 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1)) * parseFloat(row.r2) / (parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r3) + parseFloat(this.focusWRow.r4)), 2)
  1028. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1029. row.w3 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1)) * parseFloat(row.r3) / (parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r3) + parseFloat(this.focusWRow.r4)), 2)
  1030. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1031. row.w4 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1)) * parseFloat(row.r4) / (parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r3) + parseFloat(this.focusWRow.r4)), 2)
  1032. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1033. if (row.w2 <= 0) {
  1034. row.w2 = 0
  1035. row.r2 = 0
  1036. }
  1037. if (row.w3 <= 0) {
  1038. row.w3 = 0
  1039. row.r3 = 0
  1040. }
  1041. if (row.w4 <= 0) {
  1042. row.w4 = 0
  1043. row.r4 = 0
  1044. }
  1045. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1046. }
  1047. } else if (this.table.RWLength == 3) {
  1048. // 三班
  1049. // 2班/3班锁定
  1050. if (row.isTwoWeight == true && row.isThreeWeight == true) {
  1051. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1052. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3), 2))
  1053. }
  1054. // 2班不锁3班锁
  1055. if (row.isTwoWeight == false && row.isThreeWeight == true) {
  1056. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1057. row.w2 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w3), 2)
  1058. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1059. if (row.w2 <= 0) {
  1060. row.w2 = 0
  1061. row.r2 = 0
  1062. }
  1063. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3), 2))
  1064. }
  1065. // 3班不锁2班锁
  1066. if (row.isTwoWeight == true && row.isThreeWeight == false) {
  1067. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1068. row.w3 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w2), 2)
  1069. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1070. if (row.w3 <= 0) {
  1071. row.w3 = 0
  1072. row.r3 = 0
  1073. }
  1074. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3), 2))
  1075. }
  1076. // 2班3班都不锁
  1077. if (row.isTwoWeight == false && row.isThreeWeight == false) {
  1078. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1079. row.w2 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1)) * parseFloat(row.r2) / (parseFloat(row.r2) + parseFloat(row.r3)), 2)
  1080. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1081. row.w3 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1)) * parseFloat(row.r3) / (parseFloat(this.focusWRow.r2) + parseFloat(row.r3)), 2)
  1082. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1083. if (row.w3 <= 0) {
  1084. row.w3 = 0
  1085. row.r3 = 0
  1086. }
  1087. if (row.w2 <= 0) {
  1088. row.w2 = 0
  1089. row.r2 = 0
  1090. }
  1091. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3), 2))
  1092. }
  1093. } else if (this.table.RWLength == 2) {
  1094. // 两班isOneWeight,isTwoWeight
  1095. if (row.w1 == '') { row.w1 = 0 }
  1096. if (row.w2 == '') { row.w2 = 0 }
  1097. if (row.r1 == '') { row.r1 = 0 }
  1098. if (row.r2 == '') { row.r2 = 0 }
  1099. if (row.isTwoWeight == false) {
  1100. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1101. row.w2 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w1), 2)
  1102. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1103. if (row.w2 <= 0) { row.w2 = 0; row.r2 = 0 }
  1104. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2), 2))
  1105. } else {
  1106. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1107. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2), 2))
  1108. }
  1109. }
  1110. },
  1111. blurW2(row) {
  1112. // 2班重量
  1113. if (row.w1 == '') {
  1114. row.w1 = 0
  1115. }
  1116. if (row.w2 == '') {
  1117. row.w2 = 0
  1118. }
  1119. if (row.w3 == '') {
  1120. row.w3 = 0
  1121. }
  1122. if (row.w4 == '') {
  1123. row.w4 = 0
  1124. }
  1125. if (row.r1 == '') {
  1126. row.r1 = 0
  1127. }
  1128. if (row.r2 == '') {
  1129. row.r2 = 0
  1130. }
  1131. if (row.r3 == '') {
  1132. row.r3 = 0
  1133. }
  1134. if (row.r4 == '') {
  1135. row.r4 = 0
  1136. }
  1137. // row.ftweight = parseFloat(row.w1) + parseFloat(row.w2) + parseFloat(row.w3) + parseFloat(row.w4)
  1138. console.log(row, '=======投喂量feedweight')
  1139. // isOneWeight,isTwoWeight,isThreeWeight,isFourWeight
  1140. if (this.table.RWLength == 4) {
  1141. // 四班
  1142. // 1班3班4班都锁定
  1143. if (row.isOneWeight == true && row.isThreeWeight == true && row.isFourWeight == true) {
  1144. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1145. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1146. }
  1147. // 1班3班锁定4班未锁定
  1148. if (row.isOneWeight == true && row.isThreeWeight == true && row.isFourWeight == false) {
  1149. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1150. row.w4 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w2) - parseFloat(row.w3), 2)
  1151. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1152. if (row.w4 <= 0) {
  1153. row.w4 = 0
  1154. row.r4 = 0
  1155. }
  1156. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1157. }
  1158. // 1班4班锁定3班未锁定
  1159. if (row.isOneWeight == true && row.isFourWeight == true && row.isThreeWeight == false) {
  1160. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1161. row.w3 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w2) - parseFloat(row.w4), 2)
  1162. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1163. if (row.w3 <= 0) {
  1164. row.w3 = 0
  1165. row.r3 = 0
  1166. }
  1167. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1168. }
  1169. // 3班4班锁定1班未锁定
  1170. if (row.isOneWeight == false && row.isThreeWeight == true && row.isFourWeight == true) {
  1171. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1172. row.w1 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w2) - parseFloat(row.w3) - parseFloat(row.w4), 2)
  1173. row.r1 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1174. if (row.w1 <= 0) {
  1175. row.w1 = 0
  1176. row.r1 = 0
  1177. }
  1178. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1179. }
  1180. // 1班锁定,3班4班未锁
  1181. if (row.isOneWeight == true && row.isThreeWeight == false && row.isFourWeight == false) {
  1182. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1183. row.w3 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w2)) * parseFloat(row.r3) / (parseFloat(this.focusWRow.r3) + parseFloat(this.focusWRow.r4)), 2)
  1184. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1185. row.w4 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w2)) * parseFloat(row.r4) / (parseFloat(this.focusWRow.r3) + parseFloat(row.r4)), 2)
  1186. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1187. if (row.w3 <= 0) {
  1188. row.w3 = 0
  1189. row.r3 = 0
  1190. }
  1191. if (row.w4 <= 0) {
  1192. row.w4 = 0
  1193. row.r4 = 0
  1194. }
  1195. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1196. }
  1197. // 3班锁定,1班4班未锁
  1198. if (row.isOneWeight == false && row.isThreeWeight == true && row.isFourWeight == false) {
  1199. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1200. row.w1 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w2) - parseFloat(row.w3)) * parseFloat(row.r1) / (parseFloat(this.focusWRow.r1) + parseFloat(this.focusWRow.r2)), 2)
  1201. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1202. row.w4 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w2) - parseFloat(row.w3)) * parseFloat(row.r4) / (parseFloat(this.focusWRow.r1) + parseFloat(row.r2)), 2)
  1203. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1204. if (row.w1 <= 0) {
  1205. row.w1 = 0
  1206. row.r1 = 0
  1207. }
  1208. if (row.w4 <= 0) {
  1209. row.w4 = 0
  1210. row.r4 = 0
  1211. }
  1212. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1213. }
  1214. // 4班锁定,1班3班未锁
  1215. if (row.isOneWeight == false && row.isThreeWeight == false && row.isFourWeight == true) {
  1216. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1217. row.w1 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w2) - parseFloat(row.w4)) * parseFloat(row.r1) / (parseFloat(this.focusWRow.r1) + parseFloat(this.focusWRow.r3)), 2)
  1218. row.r1 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1219. row.w3 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w2) - parseFloat(row.w4)) * parseFloat(row.r3) / (parseFloat(this.focusWRow.r1) + parseFloat(row.r3)), 2)
  1220. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1221. if (row.w1 <= 0) {
  1222. row.w1 = 0
  1223. row.r1 = 0
  1224. }
  1225. if (row.w3 <= 0) {
  1226. row.w3 = 0
  1227. row.r3 = 0
  1228. }
  1229. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1230. }
  1231. // 1班3班4班未锁
  1232. if (row.isOneWeight == false && row.isThreeWeight == false && row.isFourWeight == false) {
  1233. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1234. row.w1 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w2)) * parseFloat(row.r1) / (parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r3) + parseFloat(this.focusWRow.r1)), 2)
  1235. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1236. row.w3 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w2)) * parseFloat(row.r3) / (parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r3) + parseFloat(this.focusWRow.r1)), 2)
  1237. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1238. row.w4 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w2)) * parseFloat(row.r4) / (parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r3) + parseFloat(this.focusWRow.r1)), 2)
  1239. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1240. if (row.w1 <= 0) {
  1241. row.w1 = 0
  1242. row.r1 = 0
  1243. }
  1244. if (row.w3 <= 0) {
  1245. row.w3 = 0
  1246. row.r3 = 0
  1247. }
  1248. if (row.w4 <= 0) {
  1249. row.w4 = 0
  1250. row.r4 = 0
  1251. }
  1252. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1253. }
  1254. } else if (this.table.RWLength == 3) {
  1255. // 三班
  1256. // 1班/3班锁定
  1257. if (row.isOneWeight == true && row.isThreeWeight == true) {
  1258. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1259. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3), 2))
  1260. }
  1261. // 1班不锁3班锁
  1262. if (row.isOneWeight == false && row.isThreeWeight == true) {
  1263. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1264. row.w1 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w2) - parseFloat(row.w3), 2)
  1265. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1266. if (row.w1 <= 0) {
  1267. row.w1 = 0
  1268. row.r1 = 0
  1269. }
  1270. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3), 2))
  1271. }
  1272. // 3班不锁1班锁
  1273. if (row.isOneWeight == true && row.isThreeWeight == false) {
  1274. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1275. row.w3 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w2), 2)
  1276. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1277. if (row.w3 <= 0) {
  1278. row.w3 = 0
  1279. row.r3 = 0
  1280. }
  1281. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3), 2))
  1282. }
  1283. // 1班3班都不锁
  1284. if (row.isOneWeight == false && row.isThreeWeight == false) {
  1285. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1286. row.w1 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w2)) * parseFloat(row.r1) / (parseFloat(row.r1) + parseFloat(row.r3)), 2)
  1287. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1288. row.w3 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w2)) * parseFloat(row.r3) / (parseFloat(this.focusWRow2.r1) + parseFloat(row.r3)), 2)
  1289. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1290. if (row.w3 <= 0) {
  1291. row.w3 = 0
  1292. row.r3 = 0
  1293. }
  1294. if (row.w1 <= 0) {
  1295. row.w1 = 0
  1296. row.r1 = 0
  1297. }
  1298. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3), 2))
  1299. }
  1300. } else if (this.table.RWLength == 2) {
  1301. // 两班
  1302. if (row.isTwoWeight == false) {
  1303. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1304. row.w1 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w2), 2)
  1305. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1306. if (row.w1 <= 0) { row.w1 = 0; row.r1 = 0 }
  1307. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2), 2))
  1308. } else {
  1309. row.r2 = parseFloat(row.w2) / parseFloat(row.feedweight) * 100
  1310. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2), 2))
  1311. }
  1312. }
  1313. },
  1314. blurW3(row) {
  1315. // 3班重量
  1316. if (row.w1 == '') {
  1317. row.w1 = 0
  1318. }
  1319. if (row.w2 == '') {
  1320. row.w2 = 0
  1321. }
  1322. if (row.w3 == '') {
  1323. row.w3 = 0
  1324. }
  1325. if (row.w4 == '') {
  1326. row.w4 = 0
  1327. }
  1328. if (row.r1 == '') {
  1329. row.r1 = 0
  1330. }
  1331. if (row.r2 == '') {
  1332. row.r2 = 0
  1333. }
  1334. if (row.r3 == '') {
  1335. row.r3 = 0
  1336. }
  1337. if (row.r4 == '') {
  1338. row.r4 = 0
  1339. }
  1340. // row.ftweight = parseFloat(row.w1) + parseFloat(row.w2) + parseFloat(row.w3) + parseFloat(row.w4)
  1341. console.log(row, '=======投喂量feedweight')
  1342. // isOneWeight,isTwoWeight,isThreeWeight,isFourWeight
  1343. if (this.table.RWLength == 4) {
  1344. // 四班
  1345. // 1班2班4班都锁定
  1346. if (row.isOneWeight == true && row.isTwoWeight == true && row.isFourWeight == true) {
  1347. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1348. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1349. }
  1350. // 1班2班锁定4班未锁定
  1351. if (row.isOneWeight == true && row.isTwoWeight == true && row.isFourWeight == false) {
  1352. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1353. row.w4 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w2) - parseFloat(row.w3), 2)
  1354. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1355. if (row.w4 <= 0) {
  1356. row.w4 = 0
  1357. row.r4 = 0
  1358. }
  1359. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1360. }
  1361. // 2班4班锁定1班未锁定
  1362. if (row.isOneWeight == false && row.isTwoWeight == true && row.isFourWeight == true) {
  1363. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1364. row.w1 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w2) - parseFloat(row.w3) - parseFloat(row.w4), 2)
  1365. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1366. if (row.w1 <= 0) {
  1367. row.w1 = 0
  1368. row.r1 = 0
  1369. }
  1370. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1371. }
  1372. // 1班4班锁定2班未锁定
  1373. if (row.isTwoWeight == false && row.isOneWeight == true && row.isFourWeight == true) {
  1374. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1375. row.w2 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w3) - parseFloat(row.w4), 2)
  1376. row.r2 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1377. if (row.w2 <= 0) {
  1378. row.w2 = 0
  1379. row.r2 = 0
  1380. }
  1381. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1382. }
  1383. // 2班锁定,1班4班未锁
  1384. if (row.isTwoWeight == true && row.isOneWeight == false && row.isFourWeight == false) {
  1385. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1386. row.w1 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w2) - parseFloat(row.w3)) * parseFloat(row.r1) / (parseFloat(this.focusWRow.r1) + parseFloat(this.focusWRow.r4)), 2)
  1387. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1388. row.w4 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w2) - parseFloat(row.w3)) * parseFloat(row.r4) / (parseFloat(this.focusWRow.r1) + parseFloat(row.r4)), 2)
  1389. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1390. if (row.w1 <= 0) {
  1391. row.w1 = 0
  1392. row.r1 = 0
  1393. }
  1394. if (row.w4 <= 0) {
  1395. row.w4 = 0
  1396. row.r4 = 0
  1397. }
  1398. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1399. }
  1400. // 1班锁定,2班4班未锁
  1401. if (row.isTwoWeight == false && row.isOneWeight == true && row.isFourWeight == false) {
  1402. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1403. row.w2 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w3)) * parseFloat(row.r2) / (parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r4)), 2)
  1404. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1405. row.w4 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w3)) * parseFloat(row.r4) / (parseFloat(this.focusWRow.r2) + parseFloat(row.r4)), 2)
  1406. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1407. if (row.w2 <= 0) {
  1408. row.w2 = 0
  1409. row.r2 = 0
  1410. }
  1411. if (row.w4 <= 0) {
  1412. row.w4 = 0
  1413. row.r4 = 0
  1414. }
  1415. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1416. }
  1417. // 4班锁定,2班1班未锁
  1418. if (row.isTwoWeight == false && row.isOneWeight == false && row.isFourWeight == true) {
  1419. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1420. row.w2 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w3) - parseFloat(row.w4)) * parseFloat(row.r1) / (parseFloat(this.focusWRow.r1) + parseFloat(this.focusWRow.r2)), 2)
  1421. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1422. row.w1 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w3) - parseFloat(row.w4)) * parseFloat(row.r2) / (parseFloat(this.focusWRow.r1) + parseFloat(row.r2)), 2)
  1423. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1424. if (row.w2 <= 0) {
  1425. row.w2 = 0
  1426. row.r2 = 0
  1427. }
  1428. if (row.w1 <= 0) {
  1429. row.w1 = 0
  1430. row.r1 = 0
  1431. }
  1432. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1433. }
  1434. // 2班1班4班未锁
  1435. if (row.isTwoWeight == false && row.isOneWeight == false && row.isFourWeight == false) {
  1436. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1437. row.w1 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w3)) * parseFloat(row.r1) / (parseFloat(this.focusWRow.r1) + parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r4)), 2)
  1438. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1439. row.w2 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w3)) * parseFloat(row.r2) / (parseFloat(this.focusWRow.r1) + parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r4)), 2)
  1440. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1441. row.w4 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w3)) * parseFloat(row.r4) / (parseFloat(this.focusWRow.r1) + parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r4)), 2)
  1442. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1443. if (row.w1 <= 0) {
  1444. row.w1 = 0
  1445. row.r1 = 0
  1446. }
  1447. if (row.w2 <= 0) {
  1448. row.w2 = 0
  1449. row.r2 = 0
  1450. }
  1451. if (row.w4 <= 0) {
  1452. row.w4 = 0
  1453. row.r4 = 0
  1454. }
  1455. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1456. }
  1457. } else if (this.table.RWLength == 3) {
  1458. // 三班
  1459. // 1班/2班锁定
  1460. if (row.isOneWeight == true && row.isTwoWeight == true) {
  1461. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1462. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3), 2))
  1463. }
  1464. // 1班不锁2班锁
  1465. if (row.isOneWeight == false && row.isTwoWeight == true) {
  1466. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1467. row.w1 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w2) - parseFloat(row.w3), 2)
  1468. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1469. if (row.w1 <= 0) {
  1470. row.w1 = 0
  1471. row.r1 = 0
  1472. }
  1473. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3), 2))
  1474. }
  1475. // 3班不锁2班锁
  1476. // 2班不锁1班锁
  1477. if (row.isOneWeight == true && row.isTwoWeight == false) {
  1478. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1479. row.w2 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w3), 2)
  1480. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1481. if (row.w2 <= 0) {
  1482. row.w2 = 0
  1483. row.r2 = 0
  1484. }
  1485. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3), 2))
  1486. }
  1487. // 2班3班都不锁
  1488. // 1班2班都不锁
  1489. if (row.isOneWeight == false && row.isTwoWeight == false) {
  1490. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1491. row.w1 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w3)) * parseFloat(row.r1) / (parseFloat(row.r1) + parseFloat(row.r2)), 2)
  1492. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1493. row.w2 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w3)) * parseFloat(row.r2) / (parseFloat(this.focusWRow3.r1) + parseFloat(row.r2)), 2)
  1494. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1495. if (row.w1 <= 0) {
  1496. row.w1 = 0
  1497. row.r1 = 0
  1498. }
  1499. if (row.w2 <= 0) {
  1500. row.w2 = 0
  1501. row.r2 = 0
  1502. }
  1503. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3), 2))
  1504. }
  1505. }
  1506. },
  1507. blurW4(row) {
  1508. if (row.w1 == '') {
  1509. row.w1 = 0
  1510. }
  1511. if (row.w2 == '') {
  1512. row.w2 = 0
  1513. }
  1514. if (row.w3 == '') {
  1515. row.w3 = 0
  1516. }
  1517. if (row.w4 == '') {
  1518. row.w4 = 0
  1519. }
  1520. if (row.r1 == '') {
  1521. row.r1 = 0
  1522. }
  1523. if (row.r2 == '') {
  1524. row.r2 = 0
  1525. }
  1526. if (row.r3 == '') {
  1527. row.r3 = 0
  1528. }
  1529. if (row.r4 == '') {
  1530. row.r4 = 0
  1531. }
  1532. // row.ftweight = parseFloat(row.w1) + parseFloat(row.w2) + parseFloat(row.w3) + parseFloat(row.w4)
  1533. console.log(row, '=======投喂量feedweight')
  1534. // isOneWeight,isTwoWeight,isThreeWeight,isFourWeight
  1535. if (this.table.RWLength == 4) {
  1536. // 四班
  1537. // 1班2班3班都锁定
  1538. if (row.isOneWeight == true && row.isTwoWeight == true && row.isThreeWeight == true) {
  1539. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1540. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1541. }
  1542. // 2班3班锁定1班未锁定
  1543. if (row.isOneWeight == false && row.isTwoWeight == true && row.isThreeWeight == true) {
  1544. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1545. row.w1 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w4) - parseFloat(row.w2) - parseFloat(row.w3), 2)
  1546. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1547. if (row.w1 <= 0) {
  1548. row.w1 = 0
  1549. row.r1 = 0
  1550. }
  1551. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1552. }
  1553. // 2班1班锁定3班未锁定
  1554. if (row.isOneWeight == true && row.isTwoWeight == true && row.isThreeWeight == false) {
  1555. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1556. row.w3 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w2) - parseFloat(row.w4), 2)
  1557. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1558. if (row.w3 <= 0) {
  1559. row.w3 = 0
  1560. row.r3 = 0
  1561. }
  1562. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1563. }
  1564. // 3班1班锁定2班未锁定
  1565. if (row.isOneWeight == true && row.isTwoWeight == false && row.isThreeWeight == true) {
  1566. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1567. row.w2 = formatNum(parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w3) - parseFloat(row.w4), 2)
  1568. row.r2 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1569. if (row.w2 <= 0) {
  1570. row.w2 = 0
  1571. row.r2 = 0
  1572. }
  1573. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1574. }
  1575. // 2班锁定,3班1班未锁
  1576. if (row.isOneWeight == false && row.isTwoWeight == true && row.isThreeWeight == false) {
  1577. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1578. row.w3 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w4) - parseFloat(row.w2)) * parseFloat(row.r3) / (parseFloat(this.focusWRow.r3) + parseFloat(this.focusWRow.r1)), 2)
  1579. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1580. row.w1 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w4) - parseFloat(row.w2)) * parseFloat(row.r1) / (parseFloat(this.focusWRow.r3) + parseFloat(row.r1)), 2)
  1581. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1582. if (row.w3 <= 0) {
  1583. row.w3 = 0
  1584. row.r3 = 0
  1585. }
  1586. if (row.w1 <= 0) {
  1587. row.w1 = 0
  1588. row.r1 = 0
  1589. }
  1590. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1591. }
  1592. // 3班锁定,2班1班未锁
  1593. if (row.isOneWeight == false && row.isTwoWeight == false && row.isThreeWeight == true) {
  1594. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1595. row.w2 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w4) - parseFloat(row.w3)) * parseFloat(row.r2) / (parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r1)), 2)
  1596. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1597. row.w1 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w4) - parseFloat(row.w3)) * parseFloat(row.r1) / (parseFloat(this.focusWRow.r2) + parseFloat(row.r1)), 2)
  1598. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1599. if (row.w2 <= 0) {
  1600. row.w2 = 0
  1601. row.r2 = 0
  1602. }
  1603. if (row.w1 <= 0) {
  1604. row.w1 = 0
  1605. row.r1 = 0
  1606. }
  1607. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1608. }
  1609. // 1班锁定,2班3班未锁
  1610. if (row.isOneWeight == true && row.isTwoWeight == false && row.isThreeWeight == false) {
  1611. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1612. row.w2 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w4)) * parseFloat(row.r2) / (parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r3)), 2)
  1613. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1614. row.w3 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w1) - parseFloat(row.w4)) * parseFloat(row.r3) / (parseFloat(this.focusWRow.r2) + parseFloat(row.r3)), 2)
  1615. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1616. if (row.w2 <= 0) {
  1617. row.w2 = 0
  1618. row.r2 = 0
  1619. }
  1620. if (row.w3 <= 0) {
  1621. row.w3 = 0
  1622. row.r3 = 0
  1623. }
  1624. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1625. }
  1626. // 2班3班1班未锁
  1627. if (row.isOneWeight == false && row.isTwoWeight == false && row.isThreeWeight == false) {
  1628. row.r4 = formatNum(parseFloat(row.w4) / parseFloat(row.feedweight) * 100, 2)
  1629. row.w1 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w4)) * parseFloat(row.r1) / (parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r3) + parseFloat(this.focusWRow.r1)), 2)
  1630. row.r1 = formatNum(parseFloat(row.w1) / parseFloat(row.feedweight) * 100, 2)
  1631. row.w2 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w4)) * parseFloat(row.r2) / (parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r3) + parseFloat(this.focusWRow.r1)), 2)
  1632. row.r2 = formatNum(parseFloat(row.w2) / parseFloat(row.feedweight) * 100, 2)
  1633. row.w3 = formatNum((parseFloat(row.feedweight) - parseFloat(row.w4)) * parseFloat(row.r3) / (parseFloat(this.focusWRow.r2) + parseFloat(this.focusWRow.r3) + parseFloat(this.focusWRow.r1)), 2)
  1634. row.r3 = formatNum(parseFloat(row.w3) / parseFloat(row.feedweight) * 100, 2)
  1635. if (row.w1 <= 0) {
  1636. row.w1 = 0
  1637. row.r1 = 0
  1638. }
  1639. if (row.w2 <= 0) {
  1640. row.w2 = 0
  1641. row.r2 = 0
  1642. }
  1643. if (row.w3 <= 0) {
  1644. row.w3 = 0
  1645. row.r3 = 0
  1646. }
  1647. this.$set(row, 'sumr', formatNum(parseFloat(row.r1) + parseFloat(row.r2) + parseFloat(row.r3) + parseFloat(row.r4), 2))
  1648. }
  1649. }
  1650. },
  1651. // 编辑
  1652. handleUpdate(row) {
  1653. console.log(row)
  1654. for (let i = 0; i < this.table.list.length; i++) {
  1655. if (this.table.list[i].Edit == true) {
  1656. this.$message({
  1657. type: 'error',
  1658. message: '当前内容未保存,请点击取消或保存继续进行操作',
  1659. duration: 2000
  1660. })
  1661. return false
  1662. }
  1663. }
  1664. // 编辑true,不可编辑false
  1665. row.Edit = true
  1666. row.NoEdit = false
  1667. // 编辑false,编辑保存true
  1668. row.isUpdate = false
  1669. row.isUpdateSave = true
  1670. row.ftid = String(row.ftid)
  1671. if (row.ptsfid == '-1') {
  1672. row.ptsfid = ''
  1673. }
  1674. row.ptsfid = String(row.ptsfid)
  1675. this.table.temp.ftid = row.ftid
  1676. this.table.temp.ftname = row.ftname
  1677. this.table.temp.ptsfid = row.ptsfid
  1678. this.table.temp.ptsfname = row.ptsfname
  1679. },
  1680. updateData(row) {
  1681. console.log(row)
  1682. if (row.r1 == 'NaN') { this.$set(row, 'r1', 0) }
  1683. if (row.r2 == 'NaN') { this.$set(row, 'r2', 0) }
  1684. if (row.r3 == 'NaN') { this.$set(row, 'r3', 0) }
  1685. if (row.r4 == 'NaN') { this.$set(row, 'r4', 0) }
  1686. if (row.w1 == 'NaN') { this.$set(row, 'w1', 0) }
  1687. if (row.w2 == 'NaN') { this.$set(row, 'w2', 0) }
  1688. if (row.w3 == 'NaN') { this.$set(row, 'w3', 0) }
  1689. if (row.w4 == 'NaN') { this.$set(row, 'w4', 0) }
  1690. console.log(row)
  1691. var arr = []
  1692. for (let i = 1; i <= this.table.RWLength; i++) {
  1693. var obj = {}
  1694. obj['times'] = i
  1695. obj['pastureid'] = row.pastureid
  1696. obj['barid'] = row.barid
  1697. obj['cowcount'] = row.ccount
  1698. obj['ccountradio'] = row.ccountradio
  1699. obj['ptid'] = row.ftid
  1700. if (row.ptsfid !== '') {
  1701. obj['ptsid'] = row.ptsfid
  1702. } else {
  1703. obj['ptsid'] = '-1'
  1704. }
  1705. obj['weight'] = row['w' + i]
  1706. obj['tratio'] = Math.round(row['r' + i])
  1707. arr.push(obj)
  1708. }
  1709. if (this.table.isPtsfname == 0) {
  1710. row.ptsfid = '-1'
  1711. row.ptsfname = ''
  1712. } else {
  1713. if (row.ptsfid == '') {
  1714. row.ptsfid = '-1'
  1715. row.ptsfname = ''
  1716. }
  1717. }
  1718. if (row.supplyweight == '') {
  1719. row.supplyweight = '0'
  1720. }
  1721. if (this.table.isPtsfname == false) {
  1722. row.supplyweight = '0'
  1723. }
  1724. console.log(row, '============')
  1725. this.$set(row, 'ratio', Math.floor(parseFloat(row.ratio) * 100) / 100)
  1726. this.$set(row, 'ccountratio', Math.floor(parseFloat(row.ccountratio) * 100) / 100)
  1727. row.ratio = String(row.ratio)
  1728. row.ccountratio = String(row.ccountratio)
  1729. row.sumr = Math.round(row.sumr)
  1730. this.table.rwList = arr
  1731. console.log('点击了编辑保存', row)
  1732. this.table.temp.pastureid = row.pastureid
  1733. this.table.temp.id = row.id
  1734. this.table.temp.barname = row.barname
  1735. this.table.temp.barid = row.barid
  1736. this.table.temp.ccount = row.ccount
  1737. this.table.temp.ratio = row.ratio
  1738. this.table.temp.ccountratio = row.ccountratio
  1739. this.table.temp.ftid = row.ftid
  1740. this.table.temp.ftname = row.ftname
  1741. this.table.temp.ptsfid = row.ptsfid
  1742. this.table.temp.ptsfname = row.ptsfname
  1743. this.table.temp.ftweight = row.ftweight
  1744. this.table.temp.supplyweight = row.supplyweight
  1745. this.table.temp.feedweight = row.feedweight
  1746. this.table.temp.owner = row.owner
  1747. this.table.temp.sumr = row.sumr
  1748. if (row.softccount == '') {
  1749. row.softccount = 0
  1750. }
  1751. if (row.r1 == '') {
  1752. row.r1 = 0
  1753. }
  1754. if (row.r2 == '') {
  1755. row.r2 = 0
  1756. }
  1757. if (row.r3 == '') {
  1758. row.r3 = 0
  1759. }
  1760. if (row.r4 == '') {
  1761. row.r4 = 0
  1762. }
  1763. if (row.w1 == '') {
  1764. row.w1 = 0
  1765. }
  1766. if (row.w2 == '' || row.w4 == NaN) {
  1767. row.w2 = 0
  1768. }
  1769. if (row.w3 == '' || row.w4 == NaN) {
  1770. row.w3 = 0
  1771. }
  1772. if (row.w4 == '' || row.w4 == NaN) {
  1773. row.w4 = 0
  1774. }
  1775. console.log(row, '===========')
  1776. this.table.temp.softccount = row.softccount
  1777. this.table.temp.r1 = Math.round(row.r1)
  1778. this.table.temp.r2 = Math.round(row.r2)
  1779. this.table.temp.r3 = Math.round(row.r3)
  1780. this.table.temp.r4 = Math.round(row.r4)
  1781. this.table.temp.w1 = row.w1
  1782. this.table.temp.w2 = row.w2
  1783. this.table.temp.w3 = row.w3
  1784. this.table.temp.w4 = row.w4
  1785. if (this.table.temp.ccount == '' && this.table.temp.ratio == '' && this.table.temp.ccountratio == '' && this.table.temp.ftid == '') {
  1786. this.$message({ type: 'error', message: '实际牛头数/系数/系数头数/配方模版不能为空', duration: 2000 })
  1787. return false
  1788. }
  1789. if (this.table.temp.ratio == '' && this.table.temp.ccountratio == '' && this.table.temp.ftid == '') {
  1790. this.$message({ type: 'error', message: '系数/系数头数/配方模版不能为空', duration: 2000 })
  1791. return false
  1792. }
  1793. if (this.table.temp.ccountratio == '' && this.table.temp.ftid == '') {
  1794. this.$message({ type: 'error', message: '系数头数/配方模版不能为空', duration: 2000 })
  1795. return false
  1796. }
  1797. console.log(this.table.temp.ccount, '实际牛头数不能为空')
  1798. if (this.table.temp.ccount == '') {
  1799. this.$message({ type: 'error', message: '实际牛头数不能为空', duration: 2000 })
  1800. return false
  1801. }
  1802. if (this.table.temp.ratio == '') {
  1803. this.$message({ type: 'error', message: '系数不能为空', duration: 2000 })
  1804. return false
  1805. }
  1806. if (this.table.temp.ccountratio == '') {
  1807. this.$message({ type: 'error', message: '系数头数不能为空', duration: 2000 })
  1808. return false
  1809. }
  1810. if (this.table.temp.ftid == '') {
  1811. this.$message({ type: 'error', message: '配方模版不能为空', duration: 2000 })
  1812. return false
  1813. }
  1814. const positiveInteger = /^[0-9]\d*$/
  1815. if (!positiveInteger.test(parseFloat(this.table.temp.ccount))) {
  1816. this.$message({
  1817. type: 'error',
  1818. message: '实际牛头数请输入正整数',
  1819. duration: 2000
  1820. })
  1821. return false
  1822. }
  1823. this.isokDisable = true
  1824. setTimeout(() => {
  1825. this.isokDisable = false
  1826. }, 1000)
  1827. // this.requestParam.parammaps = this.table.temp
  1828. this.requestParam.common = {
  1829. 'returnmap': '0'
  1830. }
  1831. this.requestParam.data = []
  1832. this.requestParam.data[0] = { 'name': 'updateBigFP', 'type': 'e', 'parammaps': {
  1833. pastureid: row.pastureid,
  1834. id: row.id,
  1835. barname: row.barname,
  1836. barid: row.barid,
  1837. softccount: row.softccount,
  1838. ccount: row.ccount,
  1839. ratio: row.ratio,
  1840. ccountratio: row.ccountratio,
  1841. ftid: row.ftid,
  1842. ftname: row.ftname,
  1843. ptsfid: row.ptsfid,
  1844. ptsfname: row.ptsfname,
  1845. ftweight: row.ftweight,
  1846. supplyweight: row.supplyweight,
  1847. feedweight: row.feedweight,
  1848. owner: row.owner,
  1849. sumr: row.sumr
  1850. }}
  1851. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.table.rwList }}
  1852. this.requestParam.data[1].children = []
  1853. this.requestParam.data[1].children[0] = { 'name': 'updateBigFPDetail', 'type': 'e', 'parammaps': {
  1854. pastureid: '@insertSpotList.pastureid',
  1855. barname: row.barname,
  1856. barid: '@insertSpotList.barid',
  1857. times: '@insertSpotList.times',
  1858. tratio: '@insertSpotList.tratio',
  1859. weight: '@insertSpotList.weight',
  1860. cowcount: '@insertSpotList.cowcount',
  1861. ccountradio: row.ccountratio,
  1862. ptid: '@insertSpotList.ptid',
  1863. ptsid: '@insertSpotList.ptsid',
  1864. feedweight: row.feedweight,
  1865. supplyweight: row.supplyweight,
  1866. ratio: row.ratio
  1867. }}
  1868. this.requestParam.data[2] = { 'name': 'updateLPPbyFPChange', 'type': 'e', 'parammaps': {
  1869. pastureid: row.pastureid,
  1870. fpid: row.id
  1871. }}
  1872. ExecDataByConfig(this.requestParam).then(response => {
  1873. console.log('编辑保存发送参数', this.requestParam)
  1874. if (response.msg === 'fail') {
  1875. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1876. } else {
  1877. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1878. this.getList()
  1879. }
  1880. })
  1881. },
  1882. updateCancel(row) {
  1883. console.log('点击了编辑取消')
  1884. // 编辑false,不可编辑true
  1885. row.Edit = false
  1886. row.NoEdit = true
  1887. // 编辑true,编辑保存false
  1888. row.isUpdate = true
  1889. row.isUpdateSave = false
  1890. // this.reload()
  1891. console.log(this.table.getdataListParm.offset)
  1892. this.table.getdataListParm.offset = this.table.getdataListParm.offset
  1893. this.getList()
  1894. // this.$router.push('/formulationPlan/dhedFormula')
  1895. },
  1896. cellClick(row, column, event) {
  1897. console.log(column)
  1898. },
  1899. handleSelect(val) {
  1900. console.log('勾选数据', val)
  1901. this.selectList = val
  1902. }
  1903. }
  1904. }
  1905. </script>
  1906. <style>
  1907. </style>