6dc02c16192c9fdefb5352e3287bf520b63f0f90.svn-base 98 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217
  1. <template>
  2. <div class="app-container">
  3. <!-- 配方模板表 -->
  4. <div ref="template" class="template">
  5. <p class="recipeTemplate" />
  6. <div class="operation">
  7. <el-button class="success" @click="handleCreate">新增</el-button>
  8. <el-button class="danger" @click="handleDelete">删除</el-button>
  9. <el-button class="warning" @click="handleCopy">复制</el-button>
  10. <el-button class="success" @click="handleRecipeRecord">配方记录</el-button>
  11. <el-button class="success" @click="handleHistory">生成历史</el-button>
  12. <el-button class="import" style="float: right;margin-right: 80px;" @click="handleImport">导入</el-button>
  13. <el-button class="export" style="float: right;margin-right: 10px;" @click="handleExport">导出</el-button>
  14. </div>
  15. <div class="search">
  16. <el-select v-model="table.getdataListParm.parammaps.ccname" filterable placeholder="牲畜类别" class="filter-item" clearable>
  17. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  18. </el-select>
  19. <el-select v-model="table.getdataListParm.parammaps.fttype" filterable placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  20. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  21. </el-select>
  22. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  23. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  24. </el-select>
  25. <div ref="selectInput" class="filter-item selectInput">
  26. <el-input type="text" placeholder="请点击选择搜索条件" class="Input" />
  27. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  28. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  29. <ul v-if="arrowUp" class="selectUl">
  30. <li><a>配方名称</a><el-input v-model="table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  31. <li><a>备注</a><el-input v-model="table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  32. <li><a>来源</a><el-input v-model="table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  33. <li>
  34. <div style="float: right;">
  35. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  36. <el-button class="miniSuccess" @click="handleSearch">搜索</el-button>
  37. </div>
  38. </li>
  39. </ul>
  40. </div>
  41. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  42. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  43. </div>
  44. <div class="table">
  45. <el-table
  46. :key="table.tableKey"
  47. v-loading="table.listLoading"
  48. element-loading-text="给我一点时间"
  49. :data="table.list"
  50. border
  51. fit
  52. highlight-current-row
  53. style="width: 98%;"
  54. :row-style="rowStyle"
  55. :cell-style="cellStyle"
  56. class="elTable table-fixed"
  57. @row-click="tableRowClick"
  58. @selection-change="handleSelectionChange"
  59. >
  60. <el-table-column type="selection" align="center" width="50" />
  61. <el-table-column label="序号" align="center" type="index" width="50px">
  62. <template slot-scope="scope">
  63. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="配方名称" min-width="130px" align="center">
  67. <template slot-scope="scope">
  68. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  69. <el-input v-if="scope.row.Edit" v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="配方颜色" min-width="130px" align="center">
  73. <template slot-scope="scope">
  74. <el-color-picker v-model="scope.row.tcolor" size="mini" :disabled="scope.row.NoEdit" style="margin:10px 0;" />
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="牲畜类别" min-width="150px" align="center">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.NoEdit">{{ scope.row.ccname }}</span>
  80. <el-select v-if="scope.row.Edit" v-model="scope.row.ccid" filterable placeholder="牲畜类别" class="filter-item" style="width:95%;padding:10px 0;" @change="changeLivestockType">
  81. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  82. </el-select>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="配方类型" min-width="150px" align="center">
  86. <template slot-scope="scope">
  87. <span v-if="scope.row.NoEdit">{{ scope.row.fttype }}</span>
  88. <el-select v-if="scope.row.Edit && scope.row.isCreate == true" v-model="scope.row.fttypeid" filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  89. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  90. </el-select>
  91. <el-select v-if="scope.row.Edit && scope.row.isUpdateSave == true" v-model="scope.row.fttypeid" disabled filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  92. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  93. </el-select>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="来源" min-width="110px" align="center">
  97. <template slot-scope="scope">
  98. <span>{{ scope.row.source }}</span>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="备注" min-width="110px" align="center">
  102. <template slot-scope="scope">
  103. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  104. <el-input v-if="scope.row.Edit" v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" style="width:95%;padding:10px 0;" />
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="是否启用" min-width="110px" align="center">
  108. <template slot-scope="scope">
  109. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  113. <template slot-scope="{row}">
  114. <!-- 新增 -->
  115. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData(row)">保存</el-button>
  116. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel(row)">取消</el-button>
  117. <!-- 编辑 -->
  118. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  119. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  120. <!-- 编辑保存 -->
  121. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData(row)">保存</el-button>
  122. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. </div>
  127. </div>
  128. <!-- 配方详情表 -->
  129. <div v-if="isDetail" ref="detail" class="detail" style="margin-top: 30px;">
  130. <p class="recipeDetail" />
  131. <div class="operation">
  132. <el-button class="success" @click="handleCreate2">新增</el-button>
  133. <el-button class="danger" @click="handleDelete2">删除</el-button>
  134. <el-button class="success" @click="handleSyntheticPremix">合成预混料</el-button>
  135. <div ref="selectInput2" class="filter-item selectInput">
  136. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  137. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  138. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  139. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  140. <li>
  141. <a style="width: 130px;">饲料名称</a>
  142. <el-select v-model="table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  143. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  144. </el-select>
  145. </li>
  146. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  147. <li><a style="width: 130px;">重量</a><el-input v-model="table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  148. <li>
  149. <a style="width: 130px;">搅拌延时</a>
  150. <el-select v-model="table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;" clearable>
  151. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  152. </el-select>
  153. </li>
  154. <li>
  155. <a style="width: 130px;">是否锁定牛头数比例</a>
  156. <el-select v-model="table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;" clearable>
  157. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  158. </el-select>
  159. </li>
  160. <li><a style="width: 130px;">顺序</a><el-input v-model="table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  161. <li>
  162. <div style="float: right;">
  163. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  164. <el-button class="miniSuccess" @click="handleSearch2">搜索</el-button>
  165. </div>
  166. </li>
  167. </ul>
  168. </div>
  169. <el-button class="successBorder" @click="handleSearch2">查询</el-button>
  170. <el-button class="successBorder" @click="handleRefresh2">重置</el-button>
  171. </div>
  172. <div class="table2" style="min-height: 400px;">
  173. <el-table
  174. id="table2"
  175. ref="table2"
  176. :key="table2.tableKey"
  177. v-loading="table2.listLoading"
  178. element-loading-text="给我一点时间"
  179. :data="table2.list"
  180. border
  181. fit
  182. highlight-current-row
  183. style="width: 98%;"
  184. :row-style="rowStyle"
  185. :cell-style="cellStyle"
  186. class="elTable table-fixed"
  187. row-key="id"
  188. show-summary
  189. @selection-change="handleSelectionChange2"
  190. >
  191. <el-table-column type="selection" width="60" />
  192. <el-table-column label="序号" align="center" type="index" width="50px" />
  193. <el-table-column label="饲料组" min-width="110px" align="center">
  194. <template slot-scope="scope">
  195. <span v-if="scope.row.groupNoEdit">{{ scope.row.feedgroup }}</span>
  196. <el-input v-if="scope.row.groupEdit" v-model="scope.row.feedgroup" :disabled="scope.row.isGroupDisabled" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  197. </template>
  198. </el-table-column>
  199. <el-table-column label="饲料名称" min-width="130px" align="center">
  200. <template slot-scope="scope">
  201. <span v-if="scope.row.NoEdit">{{ scope.row.fname }}</span>
  202. <el-select v-if="scope.row.Edit" v-model="scope.row.fid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFname(value, scope.row)}">
  203. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  204. </el-select>
  205. </template>
  206. </el-table-column>
  207. <el-table-column label="重量(KG)" prop="fweight" min-width="100px" align="center">
  208. <template slot-scope="scope">
  209. <span v-if="scope.row.NoEdit">{{ scope.row.fweight }}</span>
  210. <el-input v-if="scope.row.Edit" v-model="scope.row.fweight" placeholder="重量" step="0.01" type="number" style="width:95%;padding:10px 0;" />
  211. </template>
  212. </el-table-column>
  213. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  214. <template slot-scope="scope">
  215. <span v-if="scope.row.NoEdit">{{ scope.row.autosecond }}</span>
  216. <el-select v-if="scope.row.Edit" v-model="scope.row.autosecond" filterable placeholder="搅拌延时" class="filter-item" style="width:95%;padding:10px 0;">
  217. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.id" />
  218. </el-select>
  219. </template>
  220. </el-table-column>
  221. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="110px" align="center">
  222. <template slot-scope="scope">
  223. <span v-if="scope.row.NoEdit && scope.row.islockcount == '0'">否</span>
  224. <span v-if="scope.row.NoEdit && scope.row.islockcount == '1'">是</span>
  225. <el-select v-if="scope.row.Edit" v-model="scope.row.islockcount" placeholder="" class="filter-item" style="width:95%;padding:10px 0;">
  226. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  227. </el-select>
  228. </template>
  229. </el-table-column>
  230. <el-table-column label="顺序" min-width="100px" align="center">
  231. <template slot-scope="scope">
  232. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  233. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" type="number" style="width:95%;padding:10px 0;" min-number="0" @blur="blurSort(scope.row)" />
  234. </template>
  235. </el-table-column>
  236. <el-table-column label="操作" align="center" width="320" class-name="small-padding fixed-width" fixed="right">
  237. <template slot-scope="{row}">
  238. <!-- 新增 -->
  239. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData2(row)">保存</el-button>
  240. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel2(row)">取消</el-button>
  241. <!-- 编辑 -->
  242. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate2(row)">编辑</el-button>
  243. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete2(row)">删除</el-button>
  244. <!-- 编辑保存 -->
  245. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData2(row)">保存</el-button>
  246. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel2(row)">取消</el-button>
  247. <!-- 拆分预混料 -->
  248. <el-button v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false" class="miniSuccess" @click="handleSplitPremix(row)">拆分预混料</el-button>
  249. </template>
  250. </el-table-column>
  251. </el-table>
  252. </div>
  253. </div>
  254. <!-- 配方记录 -->
  255. <el-dialog :title="textMap[template.dialogStatus]" :destroy-on-close="true" :visible.sync="template.dialogFormVisible" :close-on-click-modal="false" width="90%">
  256. <div style="height: 400px;overflow: auto;margin-bottom: 30px;">
  257. <div ref="templateDialog" class="templateDialog">
  258. <p class="recipeTemplate" />
  259. <div class="operation">
  260. <el-date-picker v-model="template.table.getdataListParm.parammaps.date" type="date" placeholder="请选择历史记录时间" :clearable="false" style="width: 180px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="changeDate" />
  261. <el-button class="successBorder" @click="handleApplication">应用</el-button>
  262. </div>
  263. <div class="search">
  264. <el-select v-model="template.table.getdataListParm.parammaps.ccname" placeholder="牲畜类别" class="filter-item" clearable>
  265. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  266. </el-select>
  267. <el-select v-model="template.table.getdataListParm.parammaps.fttype" placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  268. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  269. </el-select>
  270. <el-select v-model="template.table.getdataListParm.parammaps.enable" placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  271. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  272. </el-select>
  273. <div ref="selectInput" class="filter-item selectInput">
  274. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  275. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  276. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  277. <ul v-if="arrowUp" class="selectUl">
  278. <li><a>配方名称</a><el-input v-model="template.table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  279. <li><a>备注</a><el-input v-model="template.table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  280. <li><a>来源</a><el-input v-model="template.table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  281. <li>
  282. <div style="float: right;">
  283. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  284. <el-button class="miniSuccess" @click="handleDialogSearch">搜索</el-button>
  285. </div>
  286. </li>
  287. </ul>
  288. </div>
  289. <el-button class="successBorder" @click="handleDialogSearch">查询</el-button>
  290. <el-button class="successBorder" @click="handleDialogRefresh">重置</el-button>
  291. </div>
  292. <div class="table">
  293. <el-table
  294. :key="template.table.tableKey"
  295. v-loading="template.table.listLoading"
  296. element-loading-text="给我一点时间"
  297. :data="template.table.list"
  298. border
  299. fit
  300. highlight-current-row
  301. style="width: 98%;"
  302. :row-style="rowStyle"
  303. :cell-style="cellStyle"
  304. class="elTable table-fixed"
  305. @row-click="tableRowClickDialog"
  306. >
  307. <el-table-column label="序号" align="center" type="index" width="50px">
  308. <template slot-scope="scope">
  309. <span>{{ scope.$index + (template.table.pageNum-1) * template.table.pageSize + 1 }}</span>
  310. </template>
  311. </el-table-column>
  312. <el-table-column label="配方名称" min-width="130px" align="center">
  313. <template slot-scope="scope">
  314. <span>{{ scope.row.tname }}</span>
  315. </template>
  316. </el-table-column>
  317. <el-table-column label="配方颜色" min-width="130px" align="center">
  318. <template slot-scope="scope">
  319. <el-color-picker v-model="scope.row.tcolor" size="mini" disabled style="margin:10px 0;" />
  320. </template>
  321. </el-table-column>
  322. <el-table-column label="牲畜类别" min-width="150px" align="center">
  323. <template slot-scope="scope">
  324. <span>{{ scope.row.ccname }}</span>
  325. </template>
  326. </el-table-column>
  327. <el-table-column label="配方类型" min-width="150px" align="center">
  328. <template slot-scope="scope">
  329. <span>{{ scope.row.fttype }}</span>
  330. </template>
  331. </el-table-column>
  332. <el-table-column label="来源" min-width="110px" align="center">
  333. <template slot-scope="scope">
  334. <span>{{ scope.row.source }}</span>
  335. </template>
  336. </el-table-column>
  337. <el-table-column label="备注" min-width="110px" align="center">
  338. <template slot-scope="scope">
  339. <span>{{ scope.row.remark }}</span>
  340. </template>
  341. </el-table-column>
  342. <el-table-column label="是否启用" min-width="110px" align="center">
  343. <template slot-scope="scope">
  344. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  345. </template>
  346. </el-table-column>
  347. </el-table>
  348. </div>
  349. </div>
  350. <div v-if="isDetailDialog" class="detailDialog" style="margin-top: 30px;">
  351. <p class="recipeDetail" />
  352. <div class="operation">
  353. <div ref="selectInput2" class="filter-item selectInput">
  354. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  355. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  356. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  357. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  358. <li>
  359. <a style="width: 130px;">饲料名称</a>
  360. <el-select v-model="template.table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  361. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  362. </el-select>
  363. </li>
  364. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="template.table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  365. <li><a style="width: 130px;">重量</a><el-input v-model="template.table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  366. <li>
  367. <a style="width: 130px;">搅拌延时</a>
  368. <el-select v-model="template.table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;">
  369. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  370. </el-select>
  371. </li>
  372. <li>
  373. <a style="width: 130px;">是否锁定牛头数比例</a>
  374. <el-select v-model="template.table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;">
  375. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  376. </el-select>
  377. </li>
  378. <li><a style="width: 130px;">顺序</a><el-input v-model="template.table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  379. <li>
  380. <div style="float: right;">
  381. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  382. <el-button class="miniSuccess" @click="handleDialogSearch2">搜索</el-button>
  383. </div>
  384. </li>
  385. </ul>
  386. </div>
  387. <el-button class="successBorder" @click="handleDialogSearch2">查询</el-button>
  388. <el-button class="successBorder" @click="handleDialogRefresh2">重置</el-button>
  389. </div>
  390. <div class="table2">
  391. <el-table
  392. :key="template.table2.tableKey"
  393. v-loading="template.table2.listLoading"
  394. element-loading-text="给我一点时间"
  395. :data="template.table2.list"
  396. border
  397. fit
  398. highlight-current-row
  399. style="width: 98%;"
  400. :row-style="rowStyle"
  401. :cell-style="cellStyle"
  402. class="elTable table-fixed"
  403. row-key="id"
  404. >
  405. <el-table-column label="饲料组" min-width="130px" align="center">
  406. <template slot-scope="scope">
  407. <span>{{ scope.row.feedgroup }}</span>
  408. </template>
  409. </el-table-column>
  410. <el-table-column label="饲料名称" min-width="130px" align="center">
  411. <template slot-scope="scope">
  412. <span>{{ scope.row.fname }}</span>
  413. </template>
  414. </el-table-column>
  415. <el-table-column label="重量(KG)" min-width="130px" align="center">
  416. <template slot-scope="scope">
  417. <span>{{ scope.row.fweight }}</span>
  418. </template>
  419. </el-table-column>
  420. <el-table-column label="搅拌延时(min)" min-width="130px" align="center">
  421. <template slot-scope="scope">
  422. <span>{{ scope.row.autosecondname }}</span>
  423. </template>
  424. </el-table-column>
  425. <el-table-column label="是否锁定牛头数比例" min-width="130px" align="center">
  426. <template slot-scope="scope">
  427. <span v-if="scope.row.islockcount == '0'">否</span>
  428. <span v-if="scope.row.islockcount == '1'">是</span>
  429. </template>
  430. </el-table-column>
  431. <el-table-column label="顺序" min-width="130px" align="center">
  432. <template slot-scope="scope">
  433. <span>{{ scope.row.sort }}</span>
  434. </template>
  435. </el-table-column>
  436. </el-table>
  437. </div>
  438. </div>
  439. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
  440. <el-button @click="template.dialogFormVisible = false; ">关闭</el-button>
  441. </div>
  442. </div>
  443. </el-dialog>
  444. <!-- 合成预混料 -->
  445. <el-dialog :title="textMap[detail.dialogStatus]" :destroy-on-close="true" :visible.sync="detail.dialogFormVisible" :close-on-click-modal="false" width="90%">
  446. <div class="detailDialog">
  447. <h2>饲料</h2>
  448. <div class="table1">
  449. <el-table
  450. :key="detail.tableKey"
  451. v-loading="detail.listLoading"
  452. element-loading-text="给我一点时间"
  453. :data="detail.list"
  454. fit
  455. highlight-current-row
  456. style="width: 100%;"
  457. :row-style="rowStyle"
  458. :cell-style="cellStyle"
  459. class="elTable table-fixed"
  460. show-summary
  461. >
  462. <el-table-column label="序号" align="center" type="index" width="50px" />
  463. <el-table-column label="饲料名称" min-width="130px" align="center">
  464. <template slot-scope="scope">
  465. <span>{{ scope.row.fname }}</span>
  466. </template>
  467. </el-table-column>
  468. <el-table-column prop="fweight" sortable label="重量(KG)" />
  469. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  470. <template slot-scope="scope">
  471. <span>{{ scope.row.autosecond }}</span>
  472. </template>
  473. </el-table-column>
  474. <el-table-column label="是否锁定牛头数比例" min-width="130px" align="center">
  475. <template slot-scope="scope">
  476. <span v-if="scope.row.islockcount == '0'">否</span>
  477. <span v-if="scope.row.islockcount == '1'">是</span>
  478. </template>
  479. </el-table-column>
  480. <el-table-column label="顺序" min-width="110px" align="center">
  481. <template slot-scope="scope">
  482. <span>{{ scope.row.sort }}</span>
  483. </template>
  484. </el-table-column>
  485. </el-table>
  486. </div>
  487. <h2>合成预混料</h2>
  488. <div class="table2" style="margin-bottom: 50px;">
  489. <el-table
  490. :key="detail.tableKey2"
  491. v-loading="detail.listLoading2"
  492. element-loading-text="给我一点时间"
  493. :data="detail.list2"
  494. border
  495. fit
  496. highlight-current-row
  497. style="width: 100%;"
  498. :row-style="rowStyle"
  499. :cell-style="cellStyle"
  500. class="elTable table-fixed"
  501. >
  502. <el-table-column label="配方名称" min-width="130px" align="center">
  503. <template slot-scope="scope">
  504. <el-input v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  505. </template>
  506. </el-table-column>
  507. <el-table-column label="配方颜色" min-width="130px" align="center">
  508. <template slot-scope="scope">
  509. <el-color-picker v-model="scope.row.tcolor" size="mini" style="margin:10px 0;" :disabled="detail.disabled" />
  510. </template>
  511. </el-table-column>
  512. <el-table-column label="牲畜类别" min-width="130px" align="center">
  513. <template slot-scope="scope">
  514. <el-select v-model="scope.row.ccid" placeholder="选择牲畜父类" class="filter-item" style="width:95%;padding:10px 0;" :disabled="detail.disabled" @change="changeLivestockType2">
  515. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  516. </el-select>
  517. </template>
  518. </el-table-column>
  519. <el-table-column label="配方类型" min-width="110px" align="center">
  520. <template slot-scope="scope">
  521. <span>{{ scope.row.fttype }}</span>
  522. </template>
  523. </el-table-column>
  524. <el-table-column label="来源" min-width="110px" align="center">
  525. <template slot-scope="scope">
  526. <span>{{ scope.row.source }}</span>
  527. </template>
  528. </el-table-column>
  529. <el-table-column label="备注" min-width="130px" align="center">
  530. <template slot-scope="scope">
  531. <el-input v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  532. </template>
  533. </el-table-column>
  534. <el-table-column label="是否启用" min-width="130px" align="center">
  535. <template slot-scope="scope">
  536. <el-switch v-model="scope.row.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" :disabled="detail.disabled" />
  537. </template>
  538. </el-table-column>
  539. </el-table>
  540. </div>
  541. <div slot="footer" class="dialog-footer" style="bottom: -50px;">
  542. <el-button class="cancel" @click="detail.dialogFormVisible = false; ">关闭</el-button>
  543. <el-button class="success" :disabled="isokDisable" @click="syntheticPremixData()">确认</el-button>
  544. </div>
  545. </div>
  546. </el-dialog>
  547. </div>
  548. </template>
  549. <script>
  550. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig } from '@/api/common'
  551. import Sortable from 'sortablejs'
  552. import { MessageBox } from 'element-ui'
  553. import Cookies from 'js-cookie'
  554. export default {
  555. name: 'RecipeTemplate',
  556. data() {
  557. return {
  558. requestParams: [
  559. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] },
  560. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['配方类型'] },
  561. { name: 'getFeedAndPre', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  562. ],
  563. enableList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否启用
  564. lockBullsList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否锁定牛头数比例
  565. livestockTypeList: [], // 牲畜类别
  566. formulaTypeList: [], // 配方类型
  567. feedNameList: [], // 饲料名称
  568. mixingDelayList: [{ id: '0', name: '0' }, { id: '1', name: '1' }, { id: '2', name: '2' }, { id: '3', name: '3' }, { id: '4', name: '4' }, { id: '5', name: '5' }, { id: '6', name: '6' }, { id: '7', name: '7' }, { id: '8', name: '8' }, { id: '9', name: '9' }, { id: '10', name: '10' }, { id: '11', name: '11' }, { id: '12', name: '12' }, { id: '13', name: '13' }, { id: '14', name: '14' }, { id: '15', name: '15' }], // 搅拌延时
  569. selectHistoryTimeList: [{ id: 0, name: '2020-06-10' }, { id: 1, name: '2020-06-11' }, { id: 2, name: '2020-06-12' }, { id: 3, name: '2020-06-13' }], // 请选择历史记录时间
  570. sourceList: [{ id: 0, name: '自定义' }, { id: 1, name: '集团下发' }, { id: 2, name: '导入' }], // 导入
  571. arrowDown: true,
  572. arrowUp: false,
  573. table: {
  574. getdataListParm: {
  575. name: 'getFTList',
  576. page: 1,
  577. offset: 1,
  578. pagecount: 30,
  579. returntype: 'Map',
  580. parammaps: {
  581. pastureid: Cookies.get('pastureid'),
  582. tname: '',
  583. ccid: '',
  584. ccname: '',
  585. fttypeid: '',
  586. fttype: '',
  587. remark: '',
  588. enable: ''
  589. }
  590. },
  591. tableKey: 0,
  592. list: [],
  593. total: 0,
  594. listLoading: true,
  595. temp: {}
  596. },
  597. lockCount: {
  598. getdataListParm: {
  599. name: 'getSysoptEnable',
  600. page: 1,
  601. offset: 1,
  602. pagecount: 30,
  603. returntype: 'Map',
  604. parammaps: {
  605. pastureid: Cookies.get('pastureid'),
  606. inforname: 'isLockCount'
  607. }
  608. },
  609. isLockCount: false // 是否显示是否锁定牛头数比例
  610. },
  611. isDetail: false,
  612. arrowDown2: true,
  613. arrowUp2: false,
  614. table2: {
  615. getdataListParm: {
  616. name: 'getFTdetailList',
  617. page: 1,
  618. offset: 1,
  619. pagecount: 10,
  620. returntype: 'Map',
  621. parammaps: {
  622. pastureid: Cookies.get('pastureid'),
  623. fname: '',
  624. feedgroup: '',
  625. fweight: '',
  626. autosecondname: '',
  627. islockcount: '',
  628. sort: ''
  629. }
  630. },
  631. tableKey: 0,
  632. list: [],
  633. total: 0,
  634. listLoading: true,
  635. temp: {}
  636. },
  637. isDetailDialog: false,
  638. template: {
  639. dialogFormVisible: false,
  640. dialogStatus: '',
  641. table: {
  642. getdataListParm: {
  643. name: 'getFTListDate',
  644. page: 1,
  645. offset: 1,
  646. pagecount: 10,
  647. returntype: 'Map',
  648. parammaps: {
  649. pastureid: Cookies.get('pastureid'),
  650. tname: '',
  651. ccid: '',
  652. ccname: '',
  653. fttype: '',
  654. remark: '',
  655. enable: '',
  656. date: '',
  657. source: ''
  658. }
  659. },
  660. tableKey: 0,
  661. total: 0,
  662. listLoading: true,
  663. list: []
  664. },
  665. table2: {
  666. getdataListParm: {
  667. name: 'getFTdetailListDate',
  668. page: 1,
  669. offset: 1,
  670. pagecount: 10,
  671. returntype: 'Map',
  672. parammaps: {
  673. pastureid: Cookies.get('pastureid'),
  674. fname: '',
  675. fweight: '',
  676. islockcount: '',
  677. sort: '',
  678. feedgroup: '',
  679. autosecondname: ''
  680. }
  681. },
  682. tableKey: 0,
  683. total: 0,
  684. listLoading: true,
  685. list: []
  686. },
  687. // 历史日期
  688. getdataDateParm: {
  689. name: 'getFTMaxDate',
  690. page: 1,
  691. offset: 1,
  692. pagecount: 10,
  693. returntype: 'Map',
  694. parammaps: {
  695. pastureid: Cookies.get('pastureid')
  696. }
  697. }
  698. },
  699. detail: {
  700. dialogFormVisible: false,
  701. dialogStatus: '',
  702. tableKey: 0,
  703. total: 0,
  704. listLoading: true,
  705. list: [],
  706. tableKey2: 0,
  707. total2: 0,
  708. listLoading2: false,
  709. list2: [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }],
  710. getdataListParm: {
  711. name: 'getFTDetailCompare',
  712. page: 1,
  713. offset: 1,
  714. pagecount: 10,
  715. returntype: 'Map',
  716. parammaps: {}
  717. },
  718. list3: [],
  719. disabled: false,
  720. getdataListParm2: {
  721. name: 'getFTCompare',
  722. page: 1,
  723. offset: 1,
  724. pagecount: 10,
  725. returntype: 'Map',
  726. parammaps: {}
  727. }
  728. },
  729. selectList: [],
  730. selectList2: [],
  731. textMap: {
  732. RecipeRecord: '配方记录',
  733. SyntheticPremix: '合成预混料'
  734. },
  735. requestParam: {},
  736. isokDisable: false,
  737. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  738. cellStyle: { padding: 0 + 'px' }
  739. }
  740. },
  741. mounted() {
  742. document.addEventListener('click', (e) => {
  743. if (this.$refs.selectInput !== undefined) {
  744. if (!this.$refs.selectInput.contains(e.target)) {
  745. this.arrowDown = true
  746. this.arrowUp = false
  747. } else {
  748. this.arrowDown = false
  749. this.arrowUp = true
  750. }
  751. }
  752. if (this.$refs.selectInput2 !== undefined) {
  753. if (!this.$refs.selectInput2.contains(e.target)) {
  754. this.arrowDown2 = true
  755. this.arrowUp2 = false
  756. } else {
  757. this.arrowDown2 = false
  758. this.arrowUp2 = true
  759. }
  760. }
  761. })
  762. },
  763. created() {
  764. this.getList()
  765. this.getDownList()
  766. this.getIsLockCount()
  767. },
  768. methods: {
  769. handleHistory() {
  770. MessageBox.confirm('是否确认生成历史?', {
  771. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  772. }).then(() => {
  773. this.requestParam.name = 'creatFTdate'
  774. this.requestParam.parammaps = {}
  775. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  776. PostDataByName(this.requestParam).then(response => {
  777. console.log('生成历史保存发送参数', this.requestParam)
  778. if (response.msg !== 'fail') {
  779. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  780. } else {
  781. failproccess(response, this.$notify)
  782. }
  783. })
  784. })
  785. },
  786. getDownList() {
  787. GetDataByNames(this.requestParams).then(response => {
  788. this.livestockTypeList = response.data.getDictByName.list
  789. this.formulaTypeList = response.data.getDictByName2.list
  790. this.feedNameList = response.data.getFeedAndPre.list
  791. })
  792. },
  793. // -------------------模板-----------------------------
  794. getList() {
  795. this.table.listLoading = true
  796. GetDataByName(this.table.getdataListParm).then(response => {
  797. console.log('table数据', response.data.list)
  798. if (response.data.list !== null) {
  799. for (let i = 0; i < response.data.list.length; i++) {
  800. this.$set(response.data.list[i], 'Edit', false) // 编辑
  801. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  802. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  803. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  804. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  805. }
  806. this.table.list = response.data.list
  807. this.table.pageNum = response.data.pageNum
  808. this.table.pageSize = response.data.pageSize
  809. this.table.total = response.data.total
  810. } else {
  811. this.table.list = []
  812. }
  813. setTimeout(() => {
  814. this.table.listLoading = false
  815. }, 100)
  816. })
  817. },
  818. handleSearch() {
  819. console.log('点击了查询')
  820. this.table.getdataListParm.offset = 1
  821. this.getList()
  822. this.arrowDown = true
  823. this.arrowUp = false
  824. },
  825. handleRefresh() {
  826. console.log('点击了重置')
  827. this.table.getdataListParm.offset = 1
  828. this.table.getdataListParm.parammaps.ccid = ''
  829. this.table.getdataListParm.parammaps.ccname = ''
  830. this.table.getdataListParm.parammaps.fttype = ''
  831. this.table.getdataListParm.parammaps.tname = ''
  832. this.table.getdataListParm.parammaps.remark = ''
  833. this.table.getdataListParm.parammaps.enable = ''
  834. this.table.getdataListParm.parammaps.source = ''
  835. this.getList()
  836. },
  837. // 模板新增
  838. handleCreate() {
  839. console.log('点击了新增')
  840. // 编辑true/不可编辑false
  841. // 新增操true,编辑false,编辑保存false
  842. for (let i = 0; i < this.table.list.length; i++) {
  843. if (this.table.list[i].Edit === true) {
  844. console.log(123)
  845. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  846. return false
  847. }
  848. }
  849. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'tname': '', 'tcolor': '#ccc', 'ccid': '', 'ccname': '', 'fttype': '', 'fttypeid': '', 'source': '自定义', 'remark': '' })
  850. console.log(this.table.list)
  851. },
  852. // 畜生类别
  853. changeLivestockType(item) {
  854. this.table.temp.ccname = this.livestockTypeList.find(obj => obj.value === item).label
  855. },
  856. // 配方类型
  857. changeFormulaType(item) {
  858. this.table.temp.fttype = this.formulaTypeList.find(obj => obj.value === item).label
  859. },
  860. createData(row) {
  861. console.log('点击了新增保存', row)
  862. this.table.temp.tname = row.tname
  863. this.table.temp.tcolor = row.tcolor
  864. this.table.temp.ccid = row.ccid
  865. this.table.temp.ccname = this.table.temp.ccname
  866. this.table.temp.fttype = this.table.temp.fttype
  867. this.table.temp.fttypeid = row.fttypeid
  868. this.table.temp.source = row.source
  869. this.table.temp.remark = row.remark
  870. this.table.temp.enable = row.enable
  871. this.table.temp.pastureid = Cookies.get('pastureid')
  872. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  873. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  874. return false
  875. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  876. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  877. return false
  878. } else if (this.table.temp.tname == '') {
  879. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  880. return false
  881. } else if (this.table.temp.ccid == '') {
  882. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  883. return false
  884. } else if (this.table.temp.fttypeid == '') {
  885. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  886. return false
  887. }
  888. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  889. if (pattern.test(this.table.temp.tname)) {
  890. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  891. return false
  892. }
  893. console.log(this.table.temp)
  894. this.isokDisable = true
  895. setTimeout(() => {
  896. this.isokDisable = false
  897. }, 1000)
  898. this.requestParam.name = 'insertFT'
  899. this.requestParam.parammaps = this.table.temp
  900. PostDataByName(this.requestParam).then(response => {
  901. console.log('新增保存发送参数', this.requestParam)
  902. if (response.msg !== 'fail') {
  903. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  904. this.getList()
  905. } else {
  906. failproccess(response, this.$notify)
  907. }
  908. })
  909. },
  910. createCancel(row) {
  911. console.log('点击了新增取消')
  912. for (let i = 0; i < this.table.list.length; i++) {
  913. if (row.myId === this.table.list[i].myId) {
  914. var listIndex = this.table.list.indexOf(this.table.list[i])
  915. }
  916. if (listIndex > -1) {
  917. this.table.list.splice(listIndex, 1)
  918. return
  919. }
  920. }
  921. },
  922. // 模板编辑
  923. handleUpdate(row) {
  924. for (let i = 0; i < this.table.list.length; i++) {
  925. if (this.table.list[i].Edit == true) {
  926. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  927. return false
  928. }
  929. }
  930. // 编辑true,不可编辑false
  931. row.Edit = true
  932. row.NoEdit = false
  933. // 新增false,编辑false,编辑保存true
  934. row.isCreate = false
  935. row.isUpdate = false
  936. row.isUpdateSave = true
  937. row.ccid = String(row.ccid)
  938. row.fttypeid = String(row.fttypeid)
  939. this.table.temp.ccname = row.ccname
  940. this.table.temp.fttype = row.fttype
  941. },
  942. updateData(row) {
  943. console.log('点击了编辑保存', row)
  944. this.table.temp.tname = row.tname
  945. this.table.temp.tcolor = row.tcolor
  946. this.table.temp.ccid = row.ccid
  947. this.table.temp.fttypeid = row.fttypeid
  948. this.table.temp.source = row.source
  949. this.table.temp.remark = row.remark
  950. this.table.temp.enable = row.enable
  951. this.table.temp.ccname = this.table.temp.ccname
  952. this.table.temp.fttype = this.table.temp.fttype
  953. this.table.temp.pastureid = row.pastureid
  954. this.table.temp.id = row.id
  955. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  956. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  957. return false
  958. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  959. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  960. return false
  961. } else if (this.table.temp.tname == '') {
  962. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  963. return false
  964. } else if (this.table.temp.ccid == '') {
  965. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  966. return false
  967. } else if (this.table.temp.fttypeid == '') {
  968. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  969. return false
  970. }
  971. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  972. if (pattern.test(this.table.temp.tname)) {
  973. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  974. return false
  975. }
  976. console.log(this.table.temp)
  977. this.isokDisable = true
  978. setTimeout(() => {
  979. this.isokDisable = false
  980. }, 1000)
  981. this.requestParam.name = 'updateFT'
  982. this.requestParam.parammaps = this.table.temp
  983. PostDataByName(this.requestParam).then(response => {
  984. console.log('新增保存发送参数', this.requestParam)
  985. if (response.msg !== 'fail') {
  986. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  987. this.getList()
  988. } else {
  989. failproccess(response, this.$notify)
  990. }
  991. })
  992. },
  993. updateCancel(row) {
  994. console.log('点击了编辑取消')
  995. // 编辑false,不可编辑true
  996. row.Edit = false
  997. row.NoEdit = true
  998. // 新增false,编辑true,编辑保存false
  999. row.isCreate = false
  1000. row.isUpdate = true
  1001. row.isUpdateSave = false
  1002. this.getList()
  1003. },
  1004. // 删除
  1005. handleRowDelete(row) {
  1006. console.log('点击了行内删除')
  1007. MessageBox.confirm('是否确认删除此信息?', {
  1008. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1009. }).then(() => {
  1010. this.selectList = []
  1011. this.requestParam.name = 'deleteFT'
  1012. this.requestParam.parammaps = {}
  1013. this.requestParam.parammaps.pastureid = row.pastureid
  1014. this.requestParam.parammaps.id = row.id
  1015. PostDataByName(this.requestParam).then(response => {
  1016. if (response.msg === 'fail') {
  1017. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1018. } else {
  1019. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1020. this.getList()
  1021. }
  1022. })
  1023. }).catch(() => {
  1024. this.$message({ type: 'info', message: '已取消删除' })
  1025. })
  1026. },
  1027. handleSelectionChange(val) {
  1028. console.log('勾选数据', val)
  1029. this.selectList = val
  1030. },
  1031. handleDelete() {
  1032. console.log('点击了删除')
  1033. if (this.selectList.length == 0) {
  1034. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1035. } else {
  1036. MessageBox.confirm('是否确认删除此信息?', {
  1037. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1038. }).then(() => {
  1039. console.log(this.selectList)
  1040. this.requestParam.common = { 'returnmap': '0' }
  1041. this.requestParam.data = []
  1042. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1043. this.requestParam.data[0].children = []
  1044. this.requestParam.data[0].children[0] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1045. id: '@insertSpotList.id',
  1046. pastureid: '@insertSpotList.pastureid'
  1047. }}
  1048. ExecDataByConfig(this.requestParam).then(response => {
  1049. console.log('删除保存发送参数', this.requestParam)
  1050. if (response.msg === 'fail') {
  1051. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1052. } else {
  1053. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1054. this.getList()
  1055. }
  1056. })
  1057. })
  1058. }
  1059. },
  1060. // 复制
  1061. handleCopy() {
  1062. if (this.selectList.length == 0) {
  1063. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1064. } else {
  1065. MessageBox.confirm('是否确认复制此信息?', {
  1066. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1067. }).then(() => {
  1068. console.log(this.selectList)
  1069. this.requestParam.common = { 'returnmap': '0' }
  1070. this.requestParam.data = []
  1071. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1072. this.requestParam.data[0].children = []
  1073. this.requestParam.data[0].children[0] = { 'name': 'copyFT', 'type': 'e', 'parammaps': {
  1074. ftid: '@insertSpotList.id',
  1075. pastureid: '@insertSpotList.pastureid'
  1076. }}
  1077. ExecDataByConfig(this.requestParam).then(response => {
  1078. console.log('复制保存发送参数', this.requestParam)
  1079. if (response.msg === 'fail') {
  1080. this.$notify({ title: '复制失败', message: response.data, type: 'warning', duration: 2000 })
  1081. } else {
  1082. this.$notify({ title: '', message: '复制成功', type: 'success', duration: 2000 })
  1083. this.getList()
  1084. }
  1085. })
  1086. })
  1087. }
  1088. },
  1089. // 配方记录
  1090. handleRecipeRecord() {
  1091. console.log('点击了配方记录')
  1092. this.template.dialogStatus = 'RecipeRecord'
  1093. this.template.dialogFormVisible = true
  1094. this.template.table.getdataListParm.parammaps.ccname = ''
  1095. this.template.table.getdataListParm.parammaps.fttype = ''
  1096. this.template.table.getdataListParm.parammaps.enable = ''
  1097. this.template.table.getdataListParm.parammaps.tname = ''
  1098. this.template.table.getdataListParm.parammaps.remark = ''
  1099. this.template.table.getdataListParm.parammaps.source = ''
  1100. this.template.table.getdataListParm.offset = 1
  1101. this.getDateList()
  1102. this.isDetailDialog = false
  1103. },
  1104. // 历史时间
  1105. getDateList() {
  1106. GetDataByName(this.template.getdataDateParm).then(response => {
  1107. console.log('table数据', response.data.list)
  1108. if (response.data.list !== null) {
  1109. this.template.table.getdataListParm.parammaps.date = response.data.list[0].maxdate
  1110. this.getTemplateDialogList()
  1111. } else {
  1112. this.template.table.getdataListParm.parammaps.date = ''
  1113. }
  1114. })
  1115. },
  1116. // 配方记录-模板
  1117. getTemplateDialogList() {
  1118. this.template.table.listLoading = true
  1119. GetDataByName(this.template.table.getdataListParm).then(response => {
  1120. console.log('table数据', response.data.list)
  1121. if (response.data.list !== null) {
  1122. this.template.table.list = response.data.list
  1123. this.template.table.pageNum = response.data.pageNum
  1124. this.template.table.pageSize = response.data.pageSize
  1125. this.template.table.total = response.data.total
  1126. } else {
  1127. this.template.table.list = []
  1128. }
  1129. setTimeout(() => {
  1130. this.template.table.listLoading = false
  1131. }, 100)
  1132. })
  1133. },
  1134. handleDialogSearch() {
  1135. this.template.table.getdataListParm.offset = 1
  1136. this.getTemplateDialogList()
  1137. this.arrowDown = true
  1138. this.arrowUp = false
  1139. },
  1140. handleDialogRefresh() {
  1141. this.template.table.getdataListParm.parammaps.ccname = ''
  1142. this.template.table.getdataListParm.parammaps.fttype = ''
  1143. this.template.table.getdataListParm.parammaps.enable = ''
  1144. this.template.table.getdataListParm.parammaps.tname = ''
  1145. this.template.table.getdataListParm.parammaps.remark = ''
  1146. this.template.table.getdataListParm.parammaps.source = ''
  1147. this.template.table.getdataListParm.offset = 1
  1148. this.getTemplateDialogList()
  1149. },
  1150. // 配方记录-模板行点击
  1151. tableRowClickDialog(row, column, event) {
  1152. console.log('配方记录-模板行点击')
  1153. this.isDetailDialog = true
  1154. this.template.table2.getdataListParm.parammaps.ftid = row.id
  1155. this.getDialogList()
  1156. this.getDownList()
  1157. },
  1158. getDialogList() {
  1159. this.template.table2.listLoading = true
  1160. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1161. console.log('table数据', response.data.list)
  1162. if (response.data.list !== null) {
  1163. this.template.table2.list = response.data.list
  1164. this.template.table2.pageNum = response.data.pageNum
  1165. this.template.table2.pageSize = response.data.pageSize
  1166. this.template.table2.total = response.data.total
  1167. } else {
  1168. this.template.table2.list = []
  1169. }
  1170. setTimeout(() => {
  1171. this.template.table2.listLoading = false
  1172. }, 100)
  1173. })
  1174. },
  1175. handleDialogSearch2() {
  1176. console.log('点击了查询')
  1177. this.arrowDown2 = true
  1178. this.arrowUp2 = false
  1179. this.template.table2.getdataListParm.offset = 1
  1180. this.getDialogList2()
  1181. },
  1182. handleDialogRefresh2() {
  1183. console.log('点击了重置')
  1184. this.template.table2.getdataListParm.parammaps.fname = ''
  1185. this.template.table2.getdataListParm.parammaps.feedgroup = ''
  1186. this.template.table2.getdataListParm.parammaps.fweight = ''
  1187. this.template.table2.getdataListParm.parammaps.autosecondname = ''
  1188. this.template.table2.getdataListParm.parammaps.islockcount = '0'
  1189. this.template.table2.getdataListParm.parammaps.sort = ''
  1190. this.template.table2.getdataListParm.offset = 1
  1191. this.getDialogList2()
  1192. },
  1193. getDialogList2() {
  1194. this.template.table2.listLoading = true
  1195. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1196. console.log('table数据', response.data.list)
  1197. if (response.data.list !== null) {
  1198. this.template.table2.list = response.data.list
  1199. this.template.table2.pageNum = response.data.pageNum
  1200. this.template.table2.pageSize = response.data.pageSize
  1201. this.template.table2.total = response.data.total
  1202. } else {
  1203. this.template.table2.list = []
  1204. }
  1205. this.$nextTick(function() {
  1206. window.scrollTo({
  1207. 'top': this.$refs.templateDialog.clientHeight
  1208. })
  1209. })
  1210. setTimeout(() => {
  1211. this.template.table2.listLoading = false
  1212. }, 100)
  1213. })
  1214. },
  1215. handleImport() {
  1216. console.log('点击了导入')
  1217. },
  1218. handleExport() {
  1219. console.log('点击了导出')
  1220. },
  1221. changeDate() {
  1222. this.getTemplateDialogList()
  1223. },
  1224. // 应用
  1225. handleApplication() {
  1226. console.log('点击了应用')
  1227. MessageBox.confirm('是否确认将' + this.template.table.getdataListParm.parammaps.date + '的数据应用到当前?', {
  1228. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1229. }).then(() => {
  1230. this.requestParam.name = 'applyFTdate'
  1231. this.requestParam.parammaps = {}
  1232. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1233. this.requestParam.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1234. PostDataByName(this.requestParam).then(response => {
  1235. if (response.msg === 'fail') {
  1236. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1237. } else {
  1238. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1239. this.getTemplateDialogList()
  1240. this.getList()
  1241. }
  1242. })
  1243. }).catch(() => {
  1244. this.$message({ type: 'info', message: '已取消应用' })
  1245. })
  1246. },
  1247. // 模板行点击
  1248. tableRowClick(row, column, event) {
  1249. console.log(row, column, event)
  1250. for (let i = 0; i < this.table.list.length; i++) {
  1251. if (this.table.list[i].Edit == true) {
  1252. return false
  1253. }
  1254. }
  1255. if (column.label !== '操作') {
  1256. this.isDetail = true // 点击行显示详情
  1257. this.table2.getdataListParm.parammaps.ftid = row.id
  1258. this.table2.getdataListParm.parammaps.fttypeid = row.fttypeid
  1259. this.getList2()
  1260. this.getDownList()
  1261. }
  1262. },
  1263. // -------------------详情-----------------------------
  1264. // 获取是否显示是否锁定牛头数
  1265. getIsLockCount() {
  1266. GetDataByName(this.lockCount.getdataListParm).then(response => {
  1267. console.log(response.data.list)
  1268. if (response.data.list[0].inforvalue == 0) {
  1269. this.lockCount.isLockCount = false
  1270. } else {
  1271. this.lockCount.isLockCount = true
  1272. }
  1273. })
  1274. },
  1275. // 详情
  1276. getList2() {
  1277. this.table2.listLoading = true
  1278. GetDataByName(this.table2.getdataListParm).then(response => {
  1279. console.log('table数据', response.data.list)
  1280. if (response.data.list !== null) {
  1281. for (let i = 0; i < response.data.list.length; i++) {
  1282. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1283. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1284. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  1285. this.$set(response.data.list[i], 'isGroupDisabled', false) // 饲料组编辑禁止编辑
  1286. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  1287. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1288. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1289. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1290. }
  1291. this.rowDrop()
  1292. this.table2.list = response.data.list
  1293. this.table2.pageNum = response.data.pageNum
  1294. this.table2.pageSize = response.data.pageSize
  1295. this.table2.total = response.data.total
  1296. } else {
  1297. this.table2.list = []
  1298. }
  1299. this.$nextTick(function() {
  1300. console.log(this.$refs)
  1301. console.log(this.$refs.template.clientHeight)
  1302. window.scrollTo({
  1303. 'top': this.$refs.template.clientHeight
  1304. })
  1305. })
  1306. setTimeout(() => {
  1307. this.table2.listLoading = false
  1308. }, 100)
  1309. })
  1310. },
  1311. // 行拖拽
  1312. rowDrop() {
  1313. console.log(document.querySelector('#table2 .el-table__body-wrapper tbody'))
  1314. const tbody = document.querySelector('#table2 .el-table__body-wrapper tbody')
  1315. const that = this
  1316. Sortable.create(tbody, {
  1317. onEnd({ newIndex, oldIndex }) {
  1318. const currRow = that.table2.list.splice(oldIndex, 1)[0]
  1319. that.table2.list.splice(newIndex, 0, currRow)
  1320. console.log('索引', newIndex)
  1321. console.log('拖动数据', currRow)
  1322. console.log('上', that.table2.list[newIndex - 1])
  1323. console.log('下', that.table2.list[newIndex + 1])
  1324. if (that.table2.list[newIndex - 1] === undefined) { // 拖动至最上方无值 // 顺序等于0,其他+1 // 饲料组等于饲料名称
  1325. for (let i = 0; i < that.table2.list.length; i++) {
  1326. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1 // 其他的顺序+1
  1327. }
  1328. currRow.sort = 0
  1329. currRow.feedgroup = currRow.fname
  1330. console.log('拖动至最上方无值')
  1331. } else if (currRow.sort == that.table2.list[newIndex - 1].sort) { // 拖动值顺序等于上值顺序
  1332. currRow.sort = that.table2.list[newIndex - 1].sort
  1333. console.log('拖动值顺序等于上值顺序')
  1334. } else if (that.table2.list[newIndex + 1] == undefined) { // 拖动至最下方无值 // 顺序等于上方顺序+1 // 饲料组等于饲料名称
  1335. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1336. currRow.feedgroup = currRow.fname
  1337. console.log('拖动至最下方无值')
  1338. } else if (currRow.sort == that.table2.list[newIndex + 1].sort) { // 拖动值顺序等于下值顺序
  1339. currRow.sort == that.table2.list[newIndex + 1].sort
  1340. console.log('拖动值顺序等于下值顺序')
  1341. } else if (that.table2.list[newIndex - 1].sort == that.table2.list[newIndex + 1].sort) { // 拖动至上下顺序一致,顺序/饲料组与上下保持一致
  1342. currRow.sort = that.table2.list[newIndex - 1].sort
  1343. currRow.feedgroup = that.table2.list[newIndex - 1].feedgroup
  1344. console.log('拖动至上下顺序一致')
  1345. } else if (that.table2.list[newIndex - 1].sort !== undefined && that.table2.list[newIndex + 1].sort !== undefined) { // 拖动至上下都有值
  1346. console.log('上下')
  1347. if (parseInt(that.table2.list[newIndex - 1].sort) + 1 == that.table2.list[newIndex + 1].sort) {
  1348. console.log(newIndex)
  1349. for (let i = newIndex; i < that.table2.list.length; i++) {
  1350. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1
  1351. }
  1352. }
  1353. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1354. currRow.feedgroup = currRow.fname
  1355. console.log(that.table2.list[newIndex + 1].sort)
  1356. }
  1357. that.requestParam = {}
  1358. that.requestParam.common = { 'returnmap': '0' }
  1359. that.requestParam.data = []
  1360. that.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': that.table2.list }}
  1361. that.requestParam.data[0].children = []
  1362. that.requestParam.data[0].children[0] = { 'name': 'updateFTdetailSort', 'type': 'e', 'parammaps': {
  1363. id: '@insertSpotList.id',
  1364. pastureid: '@insertSpotList.pastureid',
  1365. sort: '@insertSpotList.sort',
  1366. feedgroup: '@insertSpotList.feedgroup'
  1367. }}
  1368. ExecDataByConfig(that.requestParam).then(response => {
  1369. console.log('顺序切换保存发送参数', that.requestParam)
  1370. if (response.msg === 'fail') {
  1371. that.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1372. } else {
  1373. that.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1374. that.getList2()
  1375. }
  1376. })
  1377. }
  1378. })
  1379. },
  1380. handleSearch2() {
  1381. console.log('点击了查询')
  1382. this.arrowDown2 = true
  1383. this.arrowUp2 = false
  1384. this.table2.getdataListParm.offset = 1
  1385. this.getList2()
  1386. },
  1387. handleRefresh2() {
  1388. console.log('点击了重置')
  1389. this.table2.getdataListParm.parammaps.fname = ''
  1390. this.table2.getdataListParm.parammaps.feedgroup = ''
  1391. this.table2.getdataListParm.parammaps.fweight = ''
  1392. this.table2.getdataListParm.parammaps.autosecondname = ''
  1393. this.table2.getdataListParm.parammaps.islockcount = '0'
  1394. this.table2.getdataListParm.parammaps.sort = ''
  1395. this.table2.getdataListParm.offset = 1
  1396. this.getList2()
  1397. },
  1398. // 详情新增
  1399. handleCreate2() {
  1400. console.log('点击了详情新增', this.table2.list)
  1401. // 编辑true/不可编辑false
  1402. // 新增操true,编辑false,编辑保存false
  1403. console.log(11)
  1404. for (let i = 0; i < this.table2.list.length; i++) {
  1405. if (this.table2.list[i].Edit === true) {
  1406. console.log(123)
  1407. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1408. return false
  1409. }
  1410. }
  1411. console.log(this.table2.list)
  1412. if (this.table2.list.length == 0) {
  1413. var mysort = 0
  1414. } else {
  1415. var mysort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1416. }
  1417. this.table2.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'groupEdit': false, 'groupNoEdit': true, 'enable': 1, 'feedgroup': '', 'fid': '', 'fname': '', 'fweight': '', 'autosecond': '0', 'islockcount': '0', 'sort': mysort })
  1418. console.log(this.table2.list)
  1419. },
  1420. changeFname(item, row) {
  1421. console.log(item, row)
  1422. this.table2.temp.fname = this.feedNameList.find(obj => obj.id == item).fname
  1423. row.fname = this.feedNameList.find(obj => obj.id == item).fname
  1424. if (this.feedNameList.find(obj => obj.id == item).ispreft == '0') {
  1425. this.table2.temp.preftid = '0'
  1426. } else {
  1427. this.table2.temp.preftid = item
  1428. }
  1429. if (row.sort == '') {
  1430. row.feedgroup = this.table2.temp.fname
  1431. } else {
  1432. if (row.isCreate == true) { // 新增状态下
  1433. for (let i = 1; i < this.table2.list.length; i++) {
  1434. if (this.table2.list[i].sort == row.sort) {
  1435. console.log(this.table2.list[i])
  1436. row.feedgroup = this.table2.list[i].feedgroup
  1437. break
  1438. } else {
  1439. row.feedgroup = this.table2.temp.fname
  1440. }
  1441. }
  1442. } else if (row.isUpdateSave == true) { // 编辑状态下
  1443. var Arr = []
  1444. for (let i = 0; i < this.table2.list.length; i++) {
  1445. Arr.push(this.table2.list[i].sort)
  1446. }
  1447. var Count = 0
  1448. for (let i = 0; i < Arr.length; i++) {
  1449. if (Arr[i] == row.sort) {
  1450. Count++
  1451. }
  1452. }
  1453. for (let i = 0; i < this.table2.list.length; i++) {
  1454. if (Count > 1) {
  1455. row.feedgroup = this.table2.list[i].feedgroup
  1456. console.log(111, this.table2.list[i].feedgroup)
  1457. break
  1458. } else if (Count == 1) {
  1459. row.feedgroup = this.table2.temp.fname
  1460. console.log(222, this.table2.temp.fname)
  1461. }
  1462. }
  1463. }
  1464. }
  1465. },
  1466. blurSort(row) {
  1467. if (row.isCreate == true) {
  1468. if (row.sort !== '') {
  1469. for (let i = 1; i < this.table2.list.length; i++) {
  1470. if (this.table2.list[i].sort == parseInt(row.sort)) {
  1471. row.feedgroup = this.table2.list[i].feedgroup
  1472. return false
  1473. } else {
  1474. row.feedgroup = row.fname
  1475. }
  1476. }
  1477. } else {
  1478. row.feedgroup = row.fname
  1479. }
  1480. } else if (row.isUpdateSave == true) {
  1481. console.log(1111)
  1482. if (row.sort !== '') {
  1483. for (let i = 0; i < this.table2.list.length; i++) {
  1484. if (this.table2.list[i].sort == row.sort) {
  1485. console.log('失去焦点,行内顺序与表格某顺序相同时', this.table2.list[i])
  1486. if (this.table2.list[i].id !== row.id) {
  1487. row.isGroupDisabled = true
  1488. row.feedgroup = this.table2.list[i].feedgroup
  1489. break
  1490. }
  1491. } else {
  1492. console.log('失去焦点,行内顺序与表格某顺序不相同时')
  1493. row.isGroupDisabled = true
  1494. row.feedgroup = row.fname
  1495. }
  1496. }
  1497. } else {
  1498. row.feedgroup = row.fname
  1499. }
  1500. }
  1501. },
  1502. createData2(row) {
  1503. console.log('点击了详情新增保存', row)
  1504. this.table2.temp.pastureid = Cookies.get('pastureid')
  1505. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1506. this.table2.temp.fid = row.fid
  1507. this.table2.temp.fname = this.table2.temp.fname
  1508. this.table2.temp.fweight = row.fweight
  1509. this.table2.temp.islockcount = row.islockcount
  1510. this.table2.temp.sort = row.sort
  1511. this.table2.temp.feedgroup = row.feedgroup
  1512. this.table2.temp.preftid = this.table2.temp.preftid
  1513. this.table2.temp.autosecond = row.autosecond
  1514. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1515. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1516. return false
  1517. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1518. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1519. return false
  1520. } else if (this.table2.temp.fid == '') {
  1521. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1522. return false
  1523. } else if (this.table2.temp.fweight == '') {
  1524. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1525. return false
  1526. } else if (this.table2.temp.autosecond == '') {
  1527. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1528. return false
  1529. }
  1530. if (this.table2.temp.sort !== '') {
  1531. this.table2.temp.sort = this.table2.temp.sort
  1532. } else {
  1533. console.log(this.table2.list.length)
  1534. if (this.table2.list.length == 1) {
  1535. this.table2.temp.sort = 0
  1536. } else {
  1537. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1538. row.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1539. }
  1540. }
  1541. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1542. if (parseInt(this.table2.temp.preftid) > 0) {
  1543. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1544. return false
  1545. }
  1546. }
  1547. // 校验顺序是否>=0
  1548. var ruleSort = /^\d+$/
  1549. if (!ruleSort.test(this.table2.temp.sort)) {
  1550. this.$message({ type: 'error', message: '饲料顺序不可为负数', duration: 2000 })
  1551. return false
  1552. }
  1553. // 检验重量>0
  1554. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1555. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1556. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1557. return false
  1558. }
  1559. this.isokDisable = true
  1560. setTimeout(() => {
  1561. this.isokDisable = false
  1562. }, 1000)
  1563. this.requestParam.common = { 'returnmap': '0' }
  1564. this.requestParam.data = []
  1565. this.requestParam.data[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  1566. pastureid: this.table2.temp.pastureid,
  1567. ftid: this.table2.getdataListParm.parammaps.ftid,
  1568. fid: row.fid,
  1569. fname: this.table2.temp.fname,
  1570. fweight: row.fweight,
  1571. islockcount: row.islockcount,
  1572. sort: row.sort,
  1573. feedgroup: row.feedgroup,
  1574. preftid: this.table2.temp.preftid,
  1575. autosecond: row.autosecond
  1576. }}
  1577. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1578. pastureid: this.table2.temp.pastureid,
  1579. ftid: this.table2.getdataListParm.parammaps.ftid,
  1580. type: this.table2.getdataListParm.parammaps.fttypeid
  1581. }}
  1582. ExecDataByConfig(this.requestParam).then(response => {
  1583. console.log('新增保存发送参数', this.requestParam)
  1584. if (response.msg !== 'fail') {
  1585. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1586. this.getList2()
  1587. } else {
  1588. failproccess(response, this.$notify)
  1589. }
  1590. })
  1591. },
  1592. createCancel2(row) {
  1593. console.log('点击了详情新增取消')
  1594. for (let i = 0; i < this.table2.list.length; i++) {
  1595. if (row.myId === this.table2.list[i].myId) {
  1596. var listIndex = this.table2.list.indexOf(this.table2.list[i])
  1597. }
  1598. if (listIndex > -1) {
  1599. this.table2.list.splice(listIndex, 1)
  1600. return
  1601. }
  1602. }
  1603. this.getDialogList()
  1604. },
  1605. // 详情编辑
  1606. handleUpdate2(row) {
  1607. console.log('详情编辑', row)
  1608. row.isGroupDisabled = false
  1609. row.islockcount = String(row.islockcount)
  1610. row.fid = String(row.fid)
  1611. row.autosecond = String(row.autosecond)
  1612. this.table2.temp.fname = row.fname
  1613. this.table2.temp.preftid = row.preftid
  1614. const rowArr = []
  1615. for (let i = 0; i < this.table2.list.length; i++) {
  1616. if (this.table2.list[i].Edit == true) {
  1617. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1618. return false
  1619. }
  1620. rowArr.push(this.table2.list[i].sort)
  1621. }
  1622. var count = 0
  1623. for (let i = 0; i < rowArr.length; i++) {
  1624. if (rowArr[i] == row.sort) {
  1625. count++
  1626. }
  1627. }
  1628. // 判断是否有相同顺序,如果没有饲料组不可编辑,若有饲料组可编辑
  1629. if (count == 1) {
  1630. // 饲料组编辑false,不可编辑true
  1631. row.groupEdit = false
  1632. row.groupNoEdit = true
  1633. // 编辑true,不可编辑false
  1634. row.Edit = true
  1635. row.NoEdit = false
  1636. // 新增false,编辑false,编辑保存true
  1637. row.isCreate = false
  1638. row.isUpdate = false
  1639. row.isUpdateSave = true
  1640. } else if (count > 1) {
  1641. // 饲料组编辑true,不可编辑false
  1642. row.groupEdit = true
  1643. row.groupNoEdit = false
  1644. console.log(222)
  1645. // 编辑true,不可编辑false
  1646. row.Edit = true
  1647. row.NoEdit = false
  1648. // 新增false,编辑false,编辑保存true
  1649. row.isCreate = false
  1650. row.isUpdate = false
  1651. row.isUpdateSave = true
  1652. return false
  1653. }
  1654. },
  1655. updateData2(row) {
  1656. console.log('点击了详情编辑保存', row)
  1657. this.isokDisable = true
  1658. setTimeout(() => {
  1659. this.isokDisable = false
  1660. }, 1000)
  1661. this.table2.temp.pastureid = row.pastureid
  1662. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1663. this.table2.temp.fid = row.fid
  1664. this.table2.temp.fname = this.table2.temp.fname
  1665. this.table2.temp.fweight = row.fweight
  1666. this.table2.temp.islockcount = row.islockcount
  1667. this.table2.temp.sort = row.sort
  1668. this.table2.temp.feedgroup = row.feedgroup
  1669. this.table2.temp.preftid = this.table2.temp.preftid
  1670. this.table2.temp.autosecond = row.autosecond
  1671. this.table2.temp.id = row.id
  1672. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1673. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1674. return false
  1675. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1676. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1677. return false
  1678. } else if (this.table2.temp.fid == '') {
  1679. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1680. return false
  1681. } else if (this.table2.temp.fweight == '') {
  1682. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1683. return false
  1684. } else if (this.table2.temp.autosecond == '') {
  1685. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1686. return false
  1687. }
  1688. if (this.table2.temp.sort !== '') {
  1689. this.table2.temp.sort = this.table2.temp.sort
  1690. } else {
  1691. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1692. }
  1693. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1694. if (parseInt(this.table2.temp.preftid) > 0) {
  1695. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1696. return false
  1697. }
  1698. }
  1699. // 校验顺序是否>=0
  1700. var ruleSort = /^\d+$/
  1701. if (!ruleSort.test(this.table2.temp.sort)) {
  1702. this.$message({ type: 'error', message: '饲料顺序不可为负数', duration: 2000 })
  1703. return false
  1704. }
  1705. // 检验重量>0
  1706. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1707. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1708. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1709. return false
  1710. }
  1711. this.requestParam.common = { 'returnmap': '0' }
  1712. this.requestParam.data = []
  1713. this.requestParam.data[0] = { 'name': 'updateFTdetail', 'type': 'e', 'parammaps': {
  1714. pastureid: row.pastureid,
  1715. ftid: this.table2.getdataListParm.parammaps.ftid,
  1716. fid: row.fid,
  1717. fname: this.table2.temp.fname,
  1718. fweight: row.fweight,
  1719. islockcount: row.islockcount,
  1720. sort: row.sort,
  1721. feedgroup: row.feedgroup,
  1722. preftid: this.table2.temp.preftid,
  1723. autosecond: row.autosecond,
  1724. id: row.id
  1725. }}
  1726. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1727. pastureid: row.pastureid,
  1728. ftid: this.table2.getdataListParm.parammaps.ftid,
  1729. type: this.table2.getdataListParm.parammaps.fttypeid
  1730. }}
  1731. ExecDataByConfig(this.requestParam).then(response => {
  1732. console.log('新增保存发送参数', this.requestParam)
  1733. if (response.msg !== 'fail') {
  1734. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1735. this.getList2()
  1736. } else {
  1737. failproccess(response, this.$notify)
  1738. }
  1739. })
  1740. },
  1741. updateCancel2(row) {
  1742. console.log('点击了详情编辑取消')
  1743. // 饲料组编辑false,不可编辑true
  1744. row.groupEdit = false
  1745. row.groupNoEdit = true
  1746. // 编辑false,不可编辑true
  1747. row.Edit = false
  1748. row.NoEdit = true
  1749. // 新增false,编辑true,编辑保存false
  1750. row.isCreate = false
  1751. row.isUpdate = true
  1752. row.isUpdateSave = false
  1753. this.getList2()
  1754. },
  1755. // 详情删除
  1756. handleRowDelete2(row) {
  1757. console.log('点击了行内删除')
  1758. MessageBox.confirm('是否确认删除此信息?', {
  1759. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1760. }).then(() => {
  1761. this.requestParam.common = { 'returnmap': '0' }
  1762. this.requestParam.data = []
  1763. this.requestParam.data[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1764. pastureid: row.pastureid,
  1765. id: row.id
  1766. }}
  1767. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1768. pastureid: row.pastureid,
  1769. ftid: this.table2.getdataListParm.parammaps.ftid,
  1770. type: this.table2.getdataListParm.parammaps.fttypeid
  1771. }}
  1772. ExecDataByConfig(this.requestParam).then(response => {
  1773. console.log('新增保存发送参数', this.requestParam)
  1774. if (response.msg === 'fail') {
  1775. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1776. } else {
  1777. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1778. this.getList2()
  1779. }
  1780. })
  1781. }).catch(() => {
  1782. this.$message({ type: 'info', message: '已取消删除' })
  1783. })
  1784. },
  1785. handleSelectionChange2(val) {
  1786. console.log('勾选数据', val)
  1787. this.selectList2 = val
  1788. },
  1789. handleDelete2() {
  1790. console.log('点击了删除')
  1791. if (this.selectList2.length == 0) {
  1792. this.$message({ type: 'error', message: '请选择配方详情', duration: 2000 })
  1793. } else {
  1794. MessageBox.confirm('是否确认删除此信息?', {
  1795. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1796. }).then(() => {
  1797. console.log(this.selectList)
  1798. this.requestParam.common = { 'returnmap': '0' }
  1799. this.requestParam.data = []
  1800. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  1801. this.requestParam.data[0].children = []
  1802. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1803. id: '@insertSpotList.id',
  1804. pastureid: '@insertSpotList.pastureid'
  1805. }}
  1806. ExecDataByConfig(this.requestParam).then(response => {
  1807. console.log('删除保存发送参数', this.requestParam)
  1808. if (response.msg === 'fail') {
  1809. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1810. } else {
  1811. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1812. this.getList2()
  1813. }
  1814. })
  1815. })
  1816. }
  1817. },
  1818. // 拆分预混料
  1819. handleSplitPremix(row) {
  1820. console.log('点击了拆分预混料')
  1821. MessageBox.confirm('是否确认拆分当前预混料?', {
  1822. confirmButtonText: '确认',
  1823. cancelButtonText: '取消',
  1824. type: 'warning'
  1825. }).then(() => {
  1826. this.requestParam.name = 'splitFTpre'
  1827. this.requestParam.parammaps = {}
  1828. this.requestParam.parammaps.ftid = this.table2.getdataListParm.parammaps.ftid
  1829. this.requestParam.parammaps.preftid = row.preftid
  1830. this.requestParam.parammaps.ftdid = row.id
  1831. this.requestParam.parammaps.pastureid = row.pastureid
  1832. this.requestParam.parammaps.feedgroup = row.feedgroup
  1833. this.requestParam.parammaps.sort = row.sort
  1834. this.requestParam.parammaps.fweight = row.fweight
  1835. PostDataByName(this.requestParam).then(response => {
  1836. if (response.msg === 'fail') {
  1837. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1838. } else {
  1839. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1840. this.getList2()
  1841. }
  1842. })
  1843. }).catch(() => {
  1844. this.$message({
  1845. type: 'info',
  1846. message: '已取消删除'
  1847. })
  1848. })
  1849. },
  1850. // 合成预混料
  1851. handleSyntheticPremix() {
  1852. console.log('点击了合成预混料', this.selectList2)
  1853. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1854. this.$message({ type: 'error', message: '预混配方不可合成预混料', duration: 2000 })
  1855. return false
  1856. } else {
  1857. if (this.selectList2.length > 1) {
  1858. for (let i = 0; i < this.selectList2.length; i++) {
  1859. if (parseInt(this.selectList2[i].preftid) > 0) {
  1860. this.$message({ type: 'error', message: '不可选择预混料', duration: 2000 })
  1861. return false
  1862. }
  1863. }
  1864. if (this.selectList2[0].splitftpreid !== undefined) {
  1865. this.detail.getdataListParm.parammaps.ftid = this.selectList2[0].splitftpreid
  1866. this.detail.getdataListParm.parammaps.pastureid = this.selectList2[0].pastureid
  1867. GetDataByName(this.detail.getdataListParm).then(response => {
  1868. if (response.data.list !== null) { // 不为空时得到比对数据
  1869. this.detail.list3 = response.data.list
  1870. const sortList = [] // 声明排序数组
  1871. var fweightSum = 0 // 总重量
  1872. for (let i = 0; i < this.selectList2.length; i++) {
  1873. const obj = {}
  1874. obj.fid = this.selectList2[i].fid
  1875. obj.fweight = this.selectList2[i].fweight
  1876. fweightSum = fweightSum + parseFloat(this.selectList2[i].fweight)
  1877. sortList.push(obj)
  1878. }
  1879. // 排序
  1880. sortList.sort(function(a, b) {
  1881. return a.fid.localeCompare(b.fid)
  1882. })
  1883. var a = 0
  1884. if (this.detail.list3.length == sortList.length) {
  1885. for (let i = 0; i < this.detail.list3.length; i++) {
  1886. if (this.detail.list3[i].fid == sortList[i].fid && (this.detail.list3[i].fweight / this.detail.list3[i].sumWeight).toFixed(2) == (sortList[i].fweight / fweightSum).toFixed(2)) {
  1887. a++
  1888. }
  1889. }
  1890. if (a == this.detail.list3.length) { // 如果相等,则该配方为原预混配方
  1891. this.detail.getdataListParm2.parammaps.ftid = this.selectList2[0].splitftpreid
  1892. this.detail.getdataListParm2.parammaps.pastureid = this.selectList2[0].pastureid
  1893. GetDataByName(this.detail.getdataListParm2).then(response => {
  1894. if (response.data.list !== null) {
  1895. this.detail.dialogStatus = 'SyntheticPremix'
  1896. this.detail.dialogFormVisible = true
  1897. this.detail.list = this.selectList2
  1898. this.detail.list2 = response.data.list
  1899. this.detail.disabled = true
  1900. setTimeout(() => {
  1901. this.detail.listLoading = false
  1902. }, 100)
  1903. } else {
  1904. this.detail.list2 = []
  1905. }
  1906. })
  1907. } else {
  1908. this.detail.dialogStatus = 'SyntheticPremix'
  1909. this.detail.dialogFormVisible = true
  1910. this.detail.list = this.selectList2
  1911. this.detail.disabled = false
  1912. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1913. setTimeout(() => {
  1914. this.detail.listLoading = false
  1915. }, 100)
  1916. }
  1917. } else {
  1918. this.detail.dialogStatus = 'SyntheticPremix'
  1919. this.detail.dialogFormVisible = true
  1920. this.detail.list = this.selectList2
  1921. this.detail.disabled = false
  1922. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1923. setTimeout(() => {
  1924. this.detail.listLoading = false
  1925. }, 100)
  1926. }
  1927. } else {
  1928. this.detail.list3 = []
  1929. this.detail.dialogStatus = 'SyntheticPremix'
  1930. this.detail.dialogFormVisible = true
  1931. this.detail.list = this.selectList2
  1932. this.detail.disabled = false
  1933. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1934. setTimeout(() => {
  1935. this.detail.listLoading = false
  1936. }, 100)
  1937. }
  1938. })
  1939. } else {
  1940. this.detail.dialogStatus = 'SyntheticPremix'
  1941. this.detail.dialogFormVisible = true
  1942. this.detail.list = this.selectList2
  1943. this.detail.disabled = false
  1944. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1945. setTimeout(() => {
  1946. this.detail.listLoading = false
  1947. }, 100)
  1948. }
  1949. } else {
  1950. this.$message({ type: 'error', message: '请选择俩条及以上饲料进行合成', duration: 2000 })
  1951. return false
  1952. }
  1953. }
  1954. },
  1955. // 畜生类别
  1956. changeLivestockType2(item) {
  1957. this.detail.list2[0].ccname = this.livestockTypeList.find(obj => obj.value === item).label
  1958. },
  1959. syntheticPremixData() {
  1960. console.log('点击了合成预混料确认')
  1961. if (this.detail.disabled == true) { // 原预混料
  1962. let sumFweight = 0
  1963. for (let i = 0; i < this.detail.list.length; i++) {
  1964. sumFweight += parseFloat(this.detail.list[i].fweight)
  1965. }
  1966. sumFweight = sumFweight.toFixed(2)
  1967. this.isokDisable = true
  1968. setTimeout(() => {
  1969. this.isokDisable = false
  1970. }, 1000)
  1971. this.requestParam.common = { 'returnmap': '0' }
  1972. this.requestParam.data = []
  1973. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  1974. this.requestParam.data[0].children = []
  1975. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1976. pastureid: '@insertSpotList.pastureid',
  1977. id: '@insertSpotList.id'
  1978. }}
  1979. this.requestParam.data[1] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  1980. this.requestParam.data[1].children = []
  1981. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  1982. pastureid: Cookies.get('pastureid'),
  1983. ftid: this.table2.getdataListParm.parammaps.ftid,
  1984. fid: this.detail.list2[0].id,
  1985. fname: '@insertSpotList2.tname',
  1986. fweight: sumFweight,
  1987. islockcount: '0',
  1988. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  1989. feedgroup: this.detail.list[0].feedgroup,
  1990. preftid: this.detail.list2[0].id,
  1991. autosecond: this.detail.list[0].autosecond
  1992. }}
  1993. ExecDataByConfig(this.requestParam).then(response => {
  1994. console.log('合成预混料保存发送参数', this.requestParam)
  1995. if (response.msg === 'fail') {
  1996. const tname = new RegExp("key 'tname'")
  1997. if (tname.test(response.data)) {
  1998. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  1999. } else {
  2000. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2001. }
  2002. } else {
  2003. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2004. this.detail.dialogFormVisible = false
  2005. this.getList()
  2006. this.getList2()
  2007. this.getDownList()
  2008. }
  2009. })
  2010. } else { // 现生成预混料
  2011. if (this.detail.list2[0].tname == '' && this.detail.list2[0].ccid == '') {
  2012. this.$message({ type: 'error', message: '配方名称/牲畜类别/不能为空', duration: 2000 })
  2013. return false
  2014. } else if (this.detail.list2[0].tname == '') {
  2015. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  2016. return false
  2017. } else if (this.detail.list2[0].ccid == '') {
  2018. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  2019. return false
  2020. }
  2021. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  2022. if (pattern.test(this.detail.list2[0].tname)) {
  2023. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  2024. return false
  2025. }
  2026. let sumFweight = 0
  2027. for (let i = 0; i < this.detail.list.length; i++) {
  2028. sumFweight += parseFloat(this.detail.list[i].fweight)
  2029. }
  2030. sumFweight = sumFweight.toFixed(2)
  2031. console.log(sumFweight)
  2032. this.isokDisable = true
  2033. setTimeout(() => {
  2034. this.isokDisable = false
  2035. }, 1000)
  2036. this.requestParam.common = { 'returnmap': '0' }
  2037. this.requestParam.data = []
  2038. this.requestParam.data[0] = { 'name': 'insertFT', 'type': 'e', 'parammaps': {
  2039. pastureid: Cookies.get('pastureid'),
  2040. tcode: this.detail.list2[0].tcode,
  2041. tname: this.detail.list2[0].tname,
  2042. tcolor: this.detail.list2[0].tcolor,
  2043. ccid: this.detail.list2[0].ccid,
  2044. ccname: this.detail.list2[0].ccname,
  2045. fttype: this.detail.list2[0].fttype,
  2046. fttypeid: this.detail.list2[0].fttypeid,
  2047. source: this.detail.list2[0].source,
  2048. remark: this.detail.list2[0].remark,
  2049. enable: this.detail.list2[0].enable
  2050. }}
  2051. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2052. this.requestParam.data[1].children = []
  2053. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2054. pastureid: '@insertSpotList.pastureid',
  2055. ftid: '@insertFT.LastInsertId',
  2056. fid: '@insertSpotList.fid',
  2057. fname: '@insertSpotList.fname',
  2058. fweight: '@insertSpotList.fweight',
  2059. islockcount: '@insertSpotList.islockcount',
  2060. sort: '@insertSpotList.sort',
  2061. feedgroup: '@insertSpotList.feedgroup',
  2062. preftid: '@insertSpotList.preftid',
  2063. autosecond: '@insertSpotList.autosecond'
  2064. }}
  2065. this.requestParam.data[1].children[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2066. pastureid: '@insertSpotList.pastureid',
  2067. id: '@insertSpotList.id'
  2068. }}
  2069. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2070. this.requestParam.data[2].children = []
  2071. this.requestParam.data[2].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2072. pastureid: Cookies.get('pastureid'),
  2073. ftid: this.table2.getdataListParm.parammaps.ftid,
  2074. fid: '@insertFT.LastInsertId',
  2075. fname: '@insertSpotList2.tname',
  2076. fweight: sumFweight,
  2077. islockcount: '0',
  2078. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2079. feedgroup: this.detail.list[0].feedgroup,
  2080. preftid: '@insertFT.LastInsertId',
  2081. autosecond: this.detail.list[0].autosecond
  2082. }}
  2083. ExecDataByConfig(this.requestParam).then(response => {
  2084. console.log('合成预混料保存发送参数', this.requestParam)
  2085. if (response.msg === 'fail') {
  2086. const tname = new RegExp("key 'tname'")
  2087. if (tname.test(response.data)) {
  2088. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2089. } else {
  2090. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2091. }
  2092. } else {
  2093. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2094. this.detail.dialogFormVisible = false
  2095. this.getList()
  2096. this.getList2()
  2097. this.getDownList()
  2098. }
  2099. })
  2100. }
  2101. }
  2102. }
  2103. }
  2104. </script>
  2105. <style lang="scss" scoped>
  2106. .search{margin-top:10px;}
  2107. .table{margin-top:10px;}
  2108. .table2{margin-top:10px;}
  2109. $width:350px;
  2110. $left:325px;
  2111. .selectInput{
  2112. position: relative;
  2113. display: inline-block;
  2114. .Input{width: $width;position: relative;}
  2115. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2116. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2117. .selectUl{
  2118. z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  2119. li{
  2120. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  2121. a{float:left;width: 80px;}
  2122. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  2123. }
  2124. }
  2125. }
  2126. .template{
  2127. background: #fff;
  2128. position: relative;
  2129. .recipeTemplate{
  2130. width: 72px;
  2131. height: 70px;
  2132. position: absolute;
  2133. background: url(../../../assets/images/bg1.jpg) no-repeat;
  2134. right: 0;
  2135. top: 0;
  2136. margin: 0;
  2137. }
  2138. }
  2139. .detail{
  2140. background: #fff;
  2141. position: relative;
  2142. .recipeDetail{
  2143. width: 72px;
  2144. height: 70px;
  2145. position: absolute;
  2146. background: url(../../../assets/images/bg2.jpg) no-repeat;
  2147. right: 0;
  2148. top: 0;
  2149. margin: 0;
  2150. }
  2151. }
  2152. .templateDialog{
  2153. background: #fff;
  2154. position: relative;
  2155. .recipeTemplate{
  2156. width: 72px;
  2157. height: 70px;
  2158. position: absolute;
  2159. background: url(../../../assets/images/bg1.jpg) no-repeat;
  2160. right: 0;
  2161. top: 0;
  2162. margin: 0;
  2163. }
  2164. }
  2165. .detailDialog{
  2166. background: #fff;
  2167. position: relative;
  2168. .recipeDetail{
  2169. width: 72px;
  2170. height: 70px;
  2171. position: absolute;
  2172. background: url(../../../assets/images/bg2.jpg) no-repeat;
  2173. right: 0;
  2174. top: 0;
  2175. margin: 0;
  2176. }
  2177. }
  2178. </style>